@adatechnology/game-weapons-three 0.29.6 → 0.29.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 +1436 -123
- package/dist/index.global.js.map +1 -1
- package/package.json +13 -13
package/dist/index.global.js
CHANGED
|
@@ -18175,12 +18175,12 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
18175
18175
|
}
|
|
18176
18176
|
return pack("TorusGeometry", parameters, { vertices, normals, uvs, indices, groups: [] });
|
|
18177
18177
|
}
|
|
18178
|
-
function difference(size,
|
|
18178
|
+
function difference(size, subtract3) {
|
|
18179
18179
|
const [w, h, d] = size;
|
|
18180
18180
|
const hw = w / 2;
|
|
18181
18181
|
const hh = h / 2;
|
|
18182
18182
|
const hd = d / 2;
|
|
18183
|
-
const holes =
|
|
18183
|
+
const holes = subtract3.map((hole) => ({ x0: Math.max(-hw, Math.min(hole.min[0], hole.max[0])), x1: Math.min(hw, Math.max(hole.min[0], hole.max[0])), y0: Math.max(-hh, Math.min(hole.min[1], hole.max[1])), y1: Math.min(hh, Math.max(hole.min[1], hole.max[1])) })).filter((hole) => hole.x1 > hole.x0 && hole.y1 > hole.y0);
|
|
18184
18184
|
const cuts = (lo, hi, values) => [.../* @__PURE__ */ new Set([lo, hi, ...values.filter((v) => v > lo && v < hi)])].sort((a, b) => a - b);
|
|
18185
18185
|
const xs = cuts(-hw, hw, holes.flatMap((hole) => [hole.x0, hole.x1]));
|
|
18186
18186
|
const ys = cuts(-hh, hh, holes.flatMap((hole) => [hole.y0, hole.y1]));
|
|
@@ -20506,7 +20506,7 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
20506
20506
|
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, shade(color2, 0.7));
|
|
20507
20507
|
};
|
|
20508
20508
|
B.blinds = (M, a) => {
|
|
20509
|
-
const K = kit(M, a), { w, h } = K.dim("blinds"), y = M.y || 1, retract = M.retracted != null ? M.retracted : 0.15,
|
|
20509
|
+
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);
|
|
20510
20510
|
K.box("plain", 0, y + h - 0.05, 0, w, 0.05, 0.06, 14473424);
|
|
20511
20511
|
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);
|
|
20512
20512
|
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);
|
|
@@ -23554,6 +23554,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23554
23554
|
tension: {
|
|
23555
23555
|
elasticGPa: 200,
|
|
23556
23556
|
ultimateMPa: 400
|
|
23557
|
+
},
|
|
23558
|
+
elastic: {
|
|
23559
|
+
alongGPa: 200,
|
|
23560
|
+
shearGPa: 77
|
|
23557
23561
|
}
|
|
23558
23562
|
},
|
|
23559
23563
|
{
|
|
@@ -23592,7 +23596,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23592
23596
|
elasticGPa: 200,
|
|
23593
23597
|
absorbed: 0.2
|
|
23594
23598
|
},
|
|
23595
|
-
failureMPa: 1400
|
|
23599
|
+
failureMPa: 1400,
|
|
23600
|
+
elastic: {
|
|
23601
|
+
alongGPa: 200,
|
|
23602
|
+
shearGPa: 77
|
|
23603
|
+
}
|
|
23596
23604
|
},
|
|
23597
23605
|
{
|
|
23598
23606
|
id: "cast_iron",
|
|
@@ -23663,6 +23671,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23663
23671
|
tension: {
|
|
23664
23672
|
elasticGPa: 69,
|
|
23665
23673
|
ultimateMPa: 170
|
|
23674
|
+
},
|
|
23675
|
+
elastic: {
|
|
23676
|
+
alongGPa: 69,
|
|
23677
|
+
shearGPa: 26
|
|
23666
23678
|
}
|
|
23667
23679
|
},
|
|
23668
23680
|
{
|
|
@@ -23745,7 +23757,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23745
23757
|
tearJoules: 60
|
|
23746
23758
|
}
|
|
23747
23759
|
},
|
|
23748
|
-
failureMPa: 40
|
|
23760
|
+
failureMPa: 40,
|
|
23761
|
+
elastic: {
|
|
23762
|
+
alongGPa: 12.3,
|
|
23763
|
+
acrossGPa: 1.17,
|
|
23764
|
+
shearGPa: 1
|
|
23765
|
+
}
|
|
23749
23766
|
},
|
|
23750
23767
|
{
|
|
23751
23768
|
id: "wood_hard",
|
|
@@ -23796,7 +23813,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23796
23813
|
elasticGPa: 12,
|
|
23797
23814
|
absorbed: 0.3
|
|
23798
23815
|
},
|
|
23799
|
-
failureMPa: 80
|
|
23816
|
+
failureMPa: 80,
|
|
23817
|
+
elastic: {
|
|
23818
|
+
alongGPa: 12,
|
|
23819
|
+
acrossGPa: 1.42,
|
|
23820
|
+
shearGPa: 1.02
|
|
23821
|
+
}
|
|
23800
23822
|
},
|
|
23801
23823
|
{
|
|
23802
23824
|
id: "plywood",
|
|
@@ -23928,7 +23950,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23928
23950
|
"brittle"
|
|
23929
23951
|
],
|
|
23930
23952
|
compressive: 1e5,
|
|
23931
|
-
failureMPa: 45
|
|
23953
|
+
failureMPa: 45,
|
|
23954
|
+
elastic: {
|
|
23955
|
+
alongGPa: 70,
|
|
23956
|
+
shearGPa: 29
|
|
23957
|
+
}
|
|
23932
23958
|
},
|
|
23933
23959
|
{
|
|
23934
23960
|
id: "tempered_glass",
|
|
@@ -23963,7 +23989,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23963
23989
|
damageScale: {
|
|
23964
23990
|
shelter: 3
|
|
23965
23991
|
},
|
|
23966
|
-
failureMPa: 120
|
|
23992
|
+
failureMPa: 120,
|
|
23993
|
+
elastic: {
|
|
23994
|
+
alongGPa: 70,
|
|
23995
|
+
shearGPa: 29
|
|
23996
|
+
}
|
|
23967
23997
|
},
|
|
23968
23998
|
{
|
|
23969
23999
|
id: "ceramic",
|
|
@@ -23986,6 +24016,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23986
24016
|
heatCapacity: 1.5,
|
|
23987
24017
|
thermalShockC: 200
|
|
23988
24018
|
},
|
|
24019
|
+
visual: {
|
|
24020
|
+
innerColor: 13148794
|
|
24021
|
+
},
|
|
23989
24022
|
tags: [
|
|
23990
24023
|
"ceramic",
|
|
23991
24024
|
"brittle"
|
|
@@ -24283,7 +24316,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24283
24316
|
},
|
|
24284
24317
|
visual: {
|
|
24285
24318
|
charColor: 855309,
|
|
24286
|
-
innerColor:
|
|
24319
|
+
innerColor: 14271631
|
|
24287
24320
|
},
|
|
24288
24321
|
tags: [
|
|
24289
24322
|
"fabric",
|
|
@@ -25016,6 +25049,828 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25016
25049
|
if (ductility >= 0.3) return 1;
|
|
25017
25050
|
return (1 + 4 * (0.3 - ductility) / 0.3) * Math.min(25, Math.max(1, (0.02 / Math.max(thickness, 1e-4)) ** 2));
|
|
25018
25051
|
};
|
|
25052
|
+
var EPS22 = 1e-9;
|
|
25053
|
+
var rotateVecInto = (q, v, out) => {
|
|
25054
|
+
const qx = q[0], qy = q[1], qz = q[2], qw = q[3];
|
|
25055
|
+
const tx = 2 * (qy * v[2] - qz * v[1]);
|
|
25056
|
+
const ty = 2 * (qz * v[0] - qx * v[2]);
|
|
25057
|
+
const tz = 2 * (qx * v[1] - qy * v[0]);
|
|
25058
|
+
const x = v[0] + qw * tx + (qy * tz - qz * ty);
|
|
25059
|
+
const y = v[1] + qw * ty + (qz * tx - qx * tz);
|
|
25060
|
+
const z = v[2] + qw * tz + (qx * ty - qy * tx);
|
|
25061
|
+
out[0] = x;
|
|
25062
|
+
out[1] = y;
|
|
25063
|
+
out[2] = z;
|
|
25064
|
+
return out;
|
|
25065
|
+
};
|
|
25066
|
+
var normalizeInto = (x, y, z, out, fx, fy, fz) => {
|
|
25067
|
+
const l = Math.sqrt(x * x + y * y + z * z);
|
|
25068
|
+
if (l < EPS22) {
|
|
25069
|
+
out[0] = fx;
|
|
25070
|
+
out[1] = fy;
|
|
25071
|
+
out[2] = fz;
|
|
25072
|
+
return;
|
|
25073
|
+
}
|
|
25074
|
+
out[0] = x / l;
|
|
25075
|
+
out[1] = y / l;
|
|
25076
|
+
out[2] = z / l;
|
|
25077
|
+
};
|
|
25078
|
+
var boxInto = (size, o, d, out) => {
|
|
25079
|
+
let tmin = -Infinity, tmax = Infinity;
|
|
25080
|
+
let a0 = 0, s0 = 1;
|
|
25081
|
+
for (let i = 0; i < 3; i++) {
|
|
25082
|
+
const h = size[i] / 2;
|
|
25083
|
+
if (Math.abs(d[i]) < EPS22) {
|
|
25084
|
+
if (Math.abs(o[i]) > h) return false;
|
|
25085
|
+
continue;
|
|
25086
|
+
}
|
|
25087
|
+
let ta = (-h - o[i]) / d[i];
|
|
25088
|
+
let tb = (h - o[i]) / d[i];
|
|
25089
|
+
let sa = -1;
|
|
25090
|
+
if (ta > tb) {
|
|
25091
|
+
const t = ta;
|
|
25092
|
+
ta = tb;
|
|
25093
|
+
tb = t;
|
|
25094
|
+
sa = 1;
|
|
25095
|
+
}
|
|
25096
|
+
if (ta > tmin) {
|
|
25097
|
+
tmin = ta;
|
|
25098
|
+
a0 = i;
|
|
25099
|
+
s0 = sa;
|
|
25100
|
+
}
|
|
25101
|
+
if (tb < tmax) tmax = tb;
|
|
25102
|
+
if (tmin > tmax) return false;
|
|
25103
|
+
}
|
|
25104
|
+
if (tmax < 0 || !Number.isFinite(tmin) || !Number.isFinite(tmax)) return false;
|
|
25105
|
+
out.t0 = tmin;
|
|
25106
|
+
out.t1 = tmax;
|
|
25107
|
+
out.n0[0] = 0;
|
|
25108
|
+
out.n0[1] = 0;
|
|
25109
|
+
out.n0[2] = 0;
|
|
25110
|
+
out.n0[a0] = s0;
|
|
25111
|
+
return true;
|
|
25112
|
+
};
|
|
25113
|
+
var sphereInto = (radius, o, d, out) => {
|
|
25114
|
+
const b = o[0] * d[0] + o[1] * d[1] + o[2] * d[2];
|
|
25115
|
+
const a = d[0] * d[0] + d[1] * d[1] + d[2] * d[2];
|
|
25116
|
+
const c = o[0] * o[0] + o[1] * o[1] + o[2] * o[2] - radius * radius;
|
|
25117
|
+
const disc = b * b - a * c;
|
|
25118
|
+
if (disc < 0) return false;
|
|
25119
|
+
const sq = Math.sqrt(disc);
|
|
25120
|
+
const t0 = (-b - sq) / a;
|
|
25121
|
+
const t1 = (-b + sq) / a;
|
|
25122
|
+
if (t1 < 0) return false;
|
|
25123
|
+
out.t0 = t0;
|
|
25124
|
+
out.t1 = t1;
|
|
25125
|
+
normalizeInto(o[0] + d[0] * t0, o[1] + d[1] * t0, o[2] + d[2] * t0, out.n0, 0, 1, 0);
|
|
25126
|
+
return true;
|
|
25127
|
+
};
|
|
25128
|
+
var cylinderInto = (radius, height, o, d, out) => {
|
|
25129
|
+
const hh = height / 2;
|
|
25130
|
+
const a = d[0] * d[0] + d[2] * d[2];
|
|
25131
|
+
const c = o[0] * o[0] + o[2] * o[2] - radius * radius;
|
|
25132
|
+
let tA = -Infinity, tB = Infinity;
|
|
25133
|
+
if (a > EPS22) {
|
|
25134
|
+
const b = o[0] * d[0] + o[2] * d[2];
|
|
25135
|
+
const disc = b * b - a * c;
|
|
25136
|
+
if (disc < 0) return false;
|
|
25137
|
+
const sq = Math.sqrt(disc);
|
|
25138
|
+
tA = (-b - sq) / a;
|
|
25139
|
+
tB = (-b + sq) / a;
|
|
25140
|
+
} else if (c > 0) return false;
|
|
25141
|
+
let yA = -Infinity, yB = Infinity;
|
|
25142
|
+
if (Math.abs(d[1]) > EPS22) {
|
|
25143
|
+
yA = (-hh - o[1]) / d[1];
|
|
25144
|
+
yB = (hh - o[1]) / d[1];
|
|
25145
|
+
if (yA > yB) {
|
|
25146
|
+
const t = yA;
|
|
25147
|
+
yA = yB;
|
|
25148
|
+
yB = t;
|
|
25149
|
+
}
|
|
25150
|
+
} else if (Math.abs(o[1]) > hh) return false;
|
|
25151
|
+
const t0 = Math.max(tA, yA);
|
|
25152
|
+
const t1 = Math.min(tB, yB);
|
|
25153
|
+
if (t0 > t1 || t1 < 0 || !Number.isFinite(t0) || !Number.isFinite(t1)) return false;
|
|
25154
|
+
out.t0 = t0;
|
|
25155
|
+
out.t1 = t1;
|
|
25156
|
+
if (tA >= yA) normalizeInto(o[0] + d[0] * t0, 0, o[2] + d[2] * t0, out.n0, 1, 0, 0);
|
|
25157
|
+
else {
|
|
25158
|
+
out.n0[0] = 0;
|
|
25159
|
+
out.n0[1] = d[1] > 0 ? -1 : 1;
|
|
25160
|
+
out.n0[2] = 0;
|
|
25161
|
+
}
|
|
25162
|
+
return true;
|
|
25163
|
+
};
|
|
25164
|
+
var rayShapeInto = (s, o, d, out) => {
|
|
25165
|
+
if (s.kind === "box") return boxInto(s.size, o, d, out);
|
|
25166
|
+
if (s.kind === "sphere") return sphereInto(s.radius, o, d, out);
|
|
25167
|
+
return cylinderInto(s.radius, s.height, o, d, out);
|
|
25168
|
+
};
|
|
25169
|
+
var JOINT_FASTENERS = {
|
|
25170
|
+
screw: { diameterMm: 4.5, lateral: "predrilled", spacing: 0.2 },
|
|
25171
|
+
bolt: { diameterMm: 8, lateral: "predrilled", spacing: 0.2 },
|
|
25172
|
+
nail: { diameterMm: 3, lateral: "driven", spacing: 0.15 }
|
|
25173
|
+
};
|
|
25174
|
+
var RIGID_KINDS = /* @__PURE__ */ new Set(["glue", "weld", "fused", "mortar", "rebar"]);
|
|
25175
|
+
var RIGID_PUSH = 1e10;
|
|
25176
|
+
var RIGID_TURN = 1e8;
|
|
25177
|
+
var TOUCH = 0.01;
|
|
25178
|
+
var FOOT_BAND = 0.03;
|
|
25179
|
+
var SEAM_STATIONS = 5;
|
|
25180
|
+
var BEAM_PIECES = 4;
|
|
25181
|
+
var SLENDER = 4;
|
|
25182
|
+
var MAX_DOF = 1500;
|
|
25183
|
+
var MECHANISM = 0.5;
|
|
25184
|
+
var FOOT_FRICTION = 0.4;
|
|
25185
|
+
var UPRIGHT = 0.9;
|
|
25186
|
+
var SOFT = 1e-11;
|
|
25187
|
+
var GRAVITY2 = 9.81;
|
|
25188
|
+
var EDGE_D = 4;
|
|
25189
|
+
var ROW_D = 5;
|
|
25190
|
+
var END_D = 10;
|
|
25191
|
+
var THREAD_D = 6;
|
|
25192
|
+
var isWood = (m) => !!m.tags && m.tags.includes("wood");
|
|
25193
|
+
function fastenerStiffness(kind, a, b) {
|
|
25194
|
+
const f = JOINT_FASTENERS[kind];
|
|
25195
|
+
if (!f) return null;
|
|
25196
|
+
const woods = [a, b].filter(isWood);
|
|
25197
|
+
if (woods.length === 0) return null;
|
|
25198
|
+
const density = woods.length === 2 ? Math.sqrt(a.density * b.density) : woods[0].density;
|
|
25199
|
+
const d = f.diameterMm;
|
|
25200
|
+
const perMm = f.lateral === "predrilled" ? density ** 1.5 * d / 23 : density ** 1.5 * d ** 0.8 / 30;
|
|
25201
|
+
const lateral = perMm * 1e3 * (woods.length === 1 ? 2 : 1);
|
|
25202
|
+
const axial = kind === "screw" ? 234 * (density * d) ** 0.2 * (THREAD_D * d) ** 0.4 * 1e3 : lateral;
|
|
25203
|
+
return { lateral, axial, diameter: d / 1e3, spacing: f.spacing };
|
|
25204
|
+
}
|
|
25205
|
+
function torsionConstant(side, other) {
|
|
25206
|
+
const b = Math.max(side, other);
|
|
25207
|
+
const t = Math.min(side, other);
|
|
25208
|
+
if (b <= 0) return 0;
|
|
25209
|
+
const r = t / b;
|
|
25210
|
+
return b * t ** 3 * (1 / 3 - 0.21 * r * (1 - r ** 4 / 12));
|
|
25211
|
+
}
|
|
25212
|
+
var AXES = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
25213
|
+
function beamOf(part) {
|
|
25214
|
+
const d = part.dims;
|
|
25215
|
+
let a = 0;
|
|
25216
|
+
if (d[1] > d[a]) a = 1;
|
|
25217
|
+
if (d[2] > d[a]) a = 2;
|
|
25218
|
+
const ui = (a + 1) % 3;
|
|
25219
|
+
const vi = (a + 2) % 3;
|
|
25220
|
+
const axis2 = rotateVec(part.rotation, AXES[a]);
|
|
25221
|
+
const u = rotateVec(part.rotation, AXES[ui]);
|
|
25222
|
+
const v = rotateVec(part.rotation, AXES[vi]);
|
|
25223
|
+
const min2 = [Infinity, Infinity, Infinity];
|
|
25224
|
+
const max2 = [-Infinity, -Infinity, -Infinity];
|
|
25225
|
+
for (let i = 0; i < 8; i++) {
|
|
25226
|
+
const c = cornerOf(part, i);
|
|
25227
|
+
for (let k = 0; k < 3; k++) {
|
|
25228
|
+
min2[k] = Math.min(min2[k], c[k]);
|
|
25229
|
+
max2[k] = Math.max(max2[k], c[k]);
|
|
25230
|
+
}
|
|
25231
|
+
}
|
|
25232
|
+
return { part, axis: axis2, u, v, length: d[a], stations: [], nodes: [], min: min2, max: max2 };
|
|
25233
|
+
}
|
|
25234
|
+
function cornerOf(part, i) {
|
|
25235
|
+
const d = part.dims;
|
|
25236
|
+
const local2 = [(i & 1 ? 0.5 : -0.5) * d[0], (i & 2 ? 0.5 : -0.5) * d[1], (i & 4 ? 0.5 : -0.5) * d[2]];
|
|
25237
|
+
return vec.add(part.position, rotateVec(part.rotation, local2));
|
|
25238
|
+
}
|
|
25239
|
+
function sectionOf2(beam) {
|
|
25240
|
+
const elastic = beam.part.material.elastic;
|
|
25241
|
+
if (!elastic) return null;
|
|
25242
|
+
const d = beam.part.dims;
|
|
25243
|
+
let a = 0;
|
|
25244
|
+
if (d[1] > d[a]) a = 1;
|
|
25245
|
+
if (d[2] > d[a]) a = 2;
|
|
25246
|
+
const du = d[(a + 1) % 3];
|
|
25247
|
+
const dv = d[(a + 2) % 3];
|
|
25248
|
+
const along2 = beam.part.grain === void 0 || beam.part.grain === a;
|
|
25249
|
+
const e = (along2 ? elastic.alongGPa : elastic.acrossGPa ?? elastic.alongGPa) * 1e9;
|
|
25250
|
+
const g = elastic.shearGPa * 1e9;
|
|
25251
|
+
if (beam.part.round && a === 1) {
|
|
25252
|
+
const r = du / 2;
|
|
25253
|
+
const i = Math.PI * r ** 4 / 4;
|
|
25254
|
+
return { area: Math.PI * r * r, iu: i, iv: i, j: 2 * i, e, g };
|
|
25255
|
+
}
|
|
25256
|
+
return { area: du * dv, iu: du * dv ** 3 / 12, iv: dv * du ** 3 / 12, j: torsionConstant(du, dv), e, g };
|
|
25257
|
+
}
|
|
25258
|
+
function beamLocal(s, length2) {
|
|
25259
|
+
const k = new Float64Array(144);
|
|
25260
|
+
const set2 = (i, j, value) => {
|
|
25261
|
+
k[i * 12 + j] = value;
|
|
25262
|
+
k[j * 12 + i] = value;
|
|
25263
|
+
};
|
|
25264
|
+
const L = length2;
|
|
25265
|
+
const ea = s.e * s.area / L;
|
|
25266
|
+
const gj = s.g * s.j / L;
|
|
25267
|
+
const z = s.e * s.iv;
|
|
25268
|
+
const y = s.e * s.iu;
|
|
25269
|
+
set2(0, 0, ea);
|
|
25270
|
+
set2(0, 6, -ea);
|
|
25271
|
+
set2(6, 6, ea);
|
|
25272
|
+
set2(3, 3, gj);
|
|
25273
|
+
set2(3, 9, -gj);
|
|
25274
|
+
set2(9, 9, gj);
|
|
25275
|
+
set2(1, 1, 12 * z / L ** 3);
|
|
25276
|
+
set2(1, 5, 6 * z / L ** 2);
|
|
25277
|
+
set2(1, 7, -12 * z / L ** 3);
|
|
25278
|
+
set2(1, 11, 6 * z / L ** 2);
|
|
25279
|
+
set2(5, 5, 4 * z / L);
|
|
25280
|
+
set2(5, 7, -6 * z / L ** 2);
|
|
25281
|
+
set2(5, 11, 2 * z / L);
|
|
25282
|
+
set2(7, 7, 12 * z / L ** 3);
|
|
25283
|
+
set2(7, 11, -6 * z / L ** 2);
|
|
25284
|
+
set2(11, 11, 4 * z / L);
|
|
25285
|
+
set2(2, 2, 12 * y / L ** 3);
|
|
25286
|
+
set2(2, 4, -6 * y / L ** 2);
|
|
25287
|
+
set2(2, 8, -12 * y / L ** 3);
|
|
25288
|
+
set2(2, 10, -6 * y / L ** 2);
|
|
25289
|
+
set2(4, 4, 4 * y / L);
|
|
25290
|
+
set2(4, 8, 6 * y / L ** 2);
|
|
25291
|
+
set2(4, 10, 2 * y / L);
|
|
25292
|
+
set2(8, 8, 12 * y / L ** 3);
|
|
25293
|
+
set2(8, 10, 6 * y / L ** 2);
|
|
25294
|
+
set2(10, 10, 4 * y / L);
|
|
25295
|
+
return k;
|
|
25296
|
+
}
|
|
25297
|
+
function toObjectFrame(k, n, x, y, z) {
|
|
25298
|
+
const r = [x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2]];
|
|
25299
|
+
const half = new Float64Array(n * n);
|
|
25300
|
+
const out = new Float64Array(n * n);
|
|
25301
|
+
for (let block = 0; block < n; block += 3) {
|
|
25302
|
+
for (let col = 0; col < n; col++) {
|
|
25303
|
+
for (let i = 0; i < 3; i++) {
|
|
25304
|
+
let sum2 = 0;
|
|
25305
|
+
for (let m = 0; m < 3; m++) sum2 += r[i * 3 + m] * k[(block + m) * n + col];
|
|
25306
|
+
half[(block + i) * n + col] = sum2;
|
|
25307
|
+
}
|
|
25308
|
+
}
|
|
25309
|
+
}
|
|
25310
|
+
for (let row = 0; row < n; row++) {
|
|
25311
|
+
for (let block = 0; block < n; block += 3) {
|
|
25312
|
+
for (let i = 0; i < 3; i++) {
|
|
25313
|
+
let sum2 = 0;
|
|
25314
|
+
for (let m = 0; m < 3; m++) sum2 += half[row * n + block + m] * r[i * 3 + m];
|
|
25315
|
+
out[row * n + block + i] = sum2;
|
|
25316
|
+
}
|
|
25317
|
+
}
|
|
25318
|
+
}
|
|
25319
|
+
return out;
|
|
25320
|
+
}
|
|
25321
|
+
function armRows(arm) {
|
|
25322
|
+
const [x, y, z] = arm;
|
|
25323
|
+
return [
|
|
25324
|
+
[1, 0, 0, 0, z, -y],
|
|
25325
|
+
[0, 1, 0, -z, 0, x],
|
|
25326
|
+
[0, 0, 1, y, -x, 0]
|
|
25327
|
+
];
|
|
25328
|
+
}
|
|
25329
|
+
function stationsOf(joint2, a, b) {
|
|
25330
|
+
const lo = [0, 0, 0];
|
|
25331
|
+
const hi = [0, 0, 0];
|
|
25332
|
+
let touching = true;
|
|
25333
|
+
for (let k = 0; k < 3; k++) {
|
|
25334
|
+
lo[k] = Math.max(a.min[k], b.min[k]);
|
|
25335
|
+
hi[k] = Math.min(a.max[k], b.max[k]);
|
|
25336
|
+
if (hi[k] < lo[k] - TOUCH) touching = false;
|
|
25337
|
+
}
|
|
25338
|
+
const rigid = RIGID_KINDS.has(joint2.kind);
|
|
25339
|
+
const fastener = rigid ? null : fastenerStiffness(joint2.kind, a.part.material, b.part.material);
|
|
25340
|
+
const stiff = rigid || !fastener && JOINT_FASTENERS[joint2.kind] !== void 0;
|
|
25341
|
+
if (!stiff && !fastener) return [];
|
|
25342
|
+
if (!touching) {
|
|
25343
|
+
const frame3 = [[0, 1, 0], [1, 0, 0], [0, 0, 1]];
|
|
25344
|
+
if (stiff || !fastener) return [{ at: joint2.position, frame: frame3, push: [RIGID_PUSH, RIGID_PUSH, RIGID_PUSH], turn: [RIGID_TURN, RIGID_TURN, RIGID_TURN] }];
|
|
25345
|
+
return [{ at: joint2.position, frame: frame3, push: [fastener.axial, fastener.lateral, fastener.lateral], turn: [0, 0, 0] }];
|
|
25346
|
+
}
|
|
25347
|
+
const size = [Math.max(0, hi[0] - lo[0]), Math.max(0, hi[1] - lo[1]), Math.max(0, hi[2] - lo[2])];
|
|
25348
|
+
const middle = [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2];
|
|
25349
|
+
let n = 0;
|
|
25350
|
+
if (size[1] < size[n]) n = 1;
|
|
25351
|
+
if (size[2] < size[n]) n = 2;
|
|
25352
|
+
let w = (n + 1) % 3;
|
|
25353
|
+
let c = (n + 2) % 3;
|
|
25354
|
+
if (size[c] > size[w]) [w, c] = [c, w];
|
|
25355
|
+
const frame2 = [AXES[n], AXES[w], AXES[c]];
|
|
25356
|
+
const along2 = size[w];
|
|
25357
|
+
const across2 = size[c];
|
|
25358
|
+
const d = fastener?.diameter ?? 5e-3;
|
|
25359
|
+
const spacing = fastener?.spacing ?? 0.2;
|
|
25360
|
+
const end3 = END_D * d;
|
|
25361
|
+
const count = along2 > 2 * end3 ? 1 + Math.ceil((along2 - 2 * end3) / spacing) : 1;
|
|
25362
|
+
const stations = Math.min(count, SEAM_STATIONS);
|
|
25363
|
+
const each = count / stations;
|
|
25364
|
+
const out = [];
|
|
25365
|
+
for (let s = 0; s < stations; s++) {
|
|
25366
|
+
const t = stations === 1 ? 0 : -along2 / 2 + end3 + (along2 - 2 * end3) * s / (stations - 1);
|
|
25367
|
+
const at4 = [middle[0], middle[1], middle[2]];
|
|
25368
|
+
at4[w] = middle[w] + t;
|
|
25369
|
+
if (stiff || !fastener) {
|
|
25370
|
+
out.push({ at: at4, frame: frame2, push: [RIGID_PUSH, RIGID_PUSH, RIGID_PUSH], turn: [RIGID_TURN, RIGID_TURN, RIGID_TURN] });
|
|
25371
|
+
continue;
|
|
25372
|
+
}
|
|
25373
|
+
const rows = across2 >= (2 * EDGE_D + ROW_D) * d ? [EDGE_D * d, across2 - EDGE_D * d] : [across2 / 2];
|
|
25374
|
+
const pry = rows.reduce((sum2, r) => sum2 + r * r, 0) * fastener.axial * each;
|
|
25375
|
+
const lone = stations === 1;
|
|
25376
|
+
const pryAlong = lone ? (along2 / 2) ** 2 * fastener.axial * rows.length : 0;
|
|
25377
|
+
const twist = lone && rows.length > 1 ? rows.reduce((sum2, r) => sum2 + (r - across2 / 2) ** 2, 0) * fastener.lateral : 0;
|
|
25378
|
+
out.push({ at: at4, frame: frame2, push: [fastener.axial * rows.length * each, fastener.lateral * rows.length * each, fastener.lateral * rows.length * each], turn: [twist, pry, pryAlong] });
|
|
25379
|
+
}
|
|
25380
|
+
return out;
|
|
25381
|
+
}
|
|
25382
|
+
function solve(k, f, n) {
|
|
25383
|
+
const first = new Int32Array(n);
|
|
25384
|
+
for (let i = 0; i < n; i++) {
|
|
25385
|
+
let j = 0;
|
|
25386
|
+
while (j < i && k[i * n + j] === 0) j++;
|
|
25387
|
+
first[i] = j;
|
|
25388
|
+
}
|
|
25389
|
+
for (let i = 0; i < n; i++) {
|
|
25390
|
+
const fi = first[i];
|
|
25391
|
+
for (let j = fi; j <= i; j++) {
|
|
25392
|
+
let sum2 = k[i * n + j];
|
|
25393
|
+
const from = Math.max(fi, first[j]);
|
|
25394
|
+
for (let m = from; m < j; m++) sum2 -= k[i * n + m] * k[j * n + m];
|
|
25395
|
+
if (j === i) {
|
|
25396
|
+
if (!(sum2 > 0)) return false;
|
|
25397
|
+
k[i * n + i] = Math.sqrt(sum2);
|
|
25398
|
+
} else k[i * n + j] = sum2 / k[j * n + j];
|
|
25399
|
+
}
|
|
25400
|
+
}
|
|
25401
|
+
for (let i = 0; i < n; i++) {
|
|
25402
|
+
let sum2 = f[i];
|
|
25403
|
+
for (let m = first[i]; m < i; m++) sum2 -= k[i * n + m] * f[m];
|
|
25404
|
+
f[i] = sum2 / k[i * n + i];
|
|
25405
|
+
}
|
|
25406
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
25407
|
+
const x = f[i] / k[i * n + i];
|
|
25408
|
+
f[i] = x;
|
|
25409
|
+
for (let m = first[i]; m < i; m++) f[m] = f[m] - k[i * n + m] * x;
|
|
25410
|
+
}
|
|
25411
|
+
return true;
|
|
25412
|
+
}
|
|
25413
|
+
function hullOf(points) {
|
|
25414
|
+
const sorted = [...points].sort((p, q) => p[0] - q[0] || p[1] - q[1]);
|
|
25415
|
+
const turn2 = (o, p, q) => (p[0] - o[0]) * (q[1] - o[1]) - (p[1] - o[1]) * (q[0] - o[0]);
|
|
25416
|
+
const lower = [];
|
|
25417
|
+
for (const p of sorted) {
|
|
25418
|
+
while (lower.length >= 2 && turn2(lower[lower.length - 2], lower[lower.length - 1], p) <= 1e-12) lower.pop();
|
|
25419
|
+
lower.push([p[0], p[1]]);
|
|
25420
|
+
}
|
|
25421
|
+
const upper = [];
|
|
25422
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
25423
|
+
const p = sorted[i];
|
|
25424
|
+
while (upper.length >= 2 && turn2(upper[upper.length - 2], upper[upper.length - 1], p) <= 1e-12) upper.pop();
|
|
25425
|
+
upper.push([p[0], p[1]]);
|
|
25426
|
+
}
|
|
25427
|
+
lower.pop();
|
|
25428
|
+
upper.pop();
|
|
25429
|
+
return [...lower, ...upper];
|
|
25430
|
+
}
|
|
25431
|
+
function assemblyFlex(input) {
|
|
25432
|
+
const g = input.gravity ?? GRAVITY2;
|
|
25433
|
+
const lost = new Set(input.lost ?? []);
|
|
25434
|
+
const beams = /* @__PURE__ */ new Map();
|
|
25435
|
+
for (const part of input.parts) {
|
|
25436
|
+
if (part.mass <= 0 || Math.max(...part.dims) <= 0) continue;
|
|
25437
|
+
beams.set(part.id, beamOf(part));
|
|
25438
|
+
}
|
|
25439
|
+
if (beams.size === 0) return null;
|
|
25440
|
+
const floor2 = input.floor ?? Math.min(...[...beams.values()].map((b) => b.min[1]));
|
|
25441
|
+
const joints = input.joints.filter((j) => beams.has(j.a) && beams.has(j.b) && j.a !== j.b);
|
|
25442
|
+
const structural = (j) => RIGID_KINDS.has(j.kind) || JOINT_FASTENERS[j.kind] !== void 0;
|
|
25443
|
+
const stationed = /* @__PURE__ */ new Map();
|
|
25444
|
+
const along2 = (beam, p) => Math.max(-beam.length / 2, Math.min(beam.length / 2, vec.dot(vec.sub(p, beam.part.position), beam.axis)));
|
|
25445
|
+
for (const beam of beams.values()) beam.stations.push(-beam.length / 2, beam.length / 2);
|
|
25446
|
+
for (const joint2 of joints) {
|
|
25447
|
+
if (!structural(joint2)) continue;
|
|
25448
|
+
const a = beams.get(joint2.a);
|
|
25449
|
+
const b = beams.get(joint2.b);
|
|
25450
|
+
const stations = stationsOf(joint2, a, b);
|
|
25451
|
+
stationed.set(joint2, stations);
|
|
25452
|
+
for (const s of stations) {
|
|
25453
|
+
a.stations.push(along2(a, s.at));
|
|
25454
|
+
b.stations.push(along2(b, s.at));
|
|
25455
|
+
}
|
|
25456
|
+
}
|
|
25457
|
+
const footPoints = /* @__PURE__ */ new Map();
|
|
25458
|
+
for (const beam of beams.values()) {
|
|
25459
|
+
if (beam.min[1] > floor2 + FOOT_BAND) continue;
|
|
25460
|
+
const corners = [];
|
|
25461
|
+
for (let i = 0; i < 8; i++) {
|
|
25462
|
+
const c = cornerOf(beam.part, i);
|
|
25463
|
+
if (c[1] <= beam.min[1] + 5e-3) corners.push(c);
|
|
25464
|
+
}
|
|
25465
|
+
footPoints.set(beam.part.id, corners);
|
|
25466
|
+
for (const c of corners) beam.stations.push(along2(beam, c));
|
|
25467
|
+
}
|
|
25468
|
+
const nodes = [];
|
|
25469
|
+
for (const beam of beams.values()) {
|
|
25470
|
+
const sides = beam.part.dims.filter((d) => d !== beam.length);
|
|
25471
|
+
const merge = Math.max(2e-3, 0.5 * Math.min(...sides, beam.length));
|
|
25472
|
+
const sorted = [...beam.stations].sort((p, q) => p - q);
|
|
25473
|
+
const met = [];
|
|
25474
|
+
for (const s of sorted) if (met.length === 0 || s - met[met.length - 1] > merge) met.push(s);
|
|
25475
|
+
if (met.length > 1 && beam.length / 2 - met[met.length - 1] > 0) met[met.length - 1] = beam.length / 2;
|
|
25476
|
+
const longest = beam.length >= SLENDER * Math.max(...sides, 0) && Math.abs(beam.axis[1]) < UPRIGHT ? beam.length / BEAM_PIECES : Infinity;
|
|
25477
|
+
const kept = [];
|
|
25478
|
+
for (const [i, s] of met.entries()) {
|
|
25479
|
+
const from = met[i - 1];
|
|
25480
|
+
if (from !== void 0 && s - from > longest * 1.01) {
|
|
25481
|
+
const cuts = Math.ceil((s - from) / longest);
|
|
25482
|
+
for (let c = 1; c < cuts; c++) kept.push(from + (s - from) * c / cuts);
|
|
25483
|
+
}
|
|
25484
|
+
kept.push(s);
|
|
25485
|
+
}
|
|
25486
|
+
beam.stations = kept;
|
|
25487
|
+
beam.nodes = kept.map((s) => nodes.push({ at: vec.madd(beam.part.position, beam.axis, s) }) - 1);
|
|
25488
|
+
}
|
|
25489
|
+
if (nodes.length * 6 > MAX_DOF) return null;
|
|
25490
|
+
const lo = [Infinity, Infinity, Infinity];
|
|
25491
|
+
const hi = [-Infinity, -Infinity, -Infinity];
|
|
25492
|
+
for (const node of nodes) for (let k = 0; k < 3; k++) {
|
|
25493
|
+
lo[k] = Math.min(lo[k], node.at[k]);
|
|
25494
|
+
hi[k] = Math.max(hi[k], node.at[k]);
|
|
25495
|
+
}
|
|
25496
|
+
let main = 0;
|
|
25497
|
+
if (hi[1] - lo[1] > hi[main] - lo[main]) main = 1;
|
|
25498
|
+
if (hi[2] - lo[2] > hi[main] - lo[main]) main = 2;
|
|
25499
|
+
const ranked = nodes.map((_, i) => i).sort((p, q) => nodes[p].at[main] - nodes[q].at[main] || p - q);
|
|
25500
|
+
const order2 = new Int32Array(nodes.length);
|
|
25501
|
+
ranked.forEach((node, rank) => {
|
|
25502
|
+
order2[node] = rank;
|
|
25503
|
+
});
|
|
25504
|
+
const dofsOf = (node) => [0, 1, 2, 3, 4, 5].map((i) => order2[node] * 6 + i);
|
|
25505
|
+
const nearest = (beam, p) => {
|
|
25506
|
+
const t = along2(beam, p);
|
|
25507
|
+
let best = 0;
|
|
25508
|
+
for (let i = 1; i < beam.stations.length; i++) if (Math.abs(beam.stations[i] - t) < Math.abs(beam.stations[best] - t)) best = i;
|
|
25509
|
+
return beam.nodes[best];
|
|
25510
|
+
};
|
|
25511
|
+
const elements = [];
|
|
25512
|
+
for (const beam of beams.values()) {
|
|
25513
|
+
const section = sectionOf2(beam);
|
|
25514
|
+
if (!section) {
|
|
25515
|
+
const id = beam.part.id;
|
|
25516
|
+
if (footPoints.has(id) || joints.some((j) => structural(j) && (j.a === id || j.b === id))) return null;
|
|
25517
|
+
continue;
|
|
25518
|
+
}
|
|
25519
|
+
for (let i = 0; i + 1 < beam.nodes.length; i++) {
|
|
25520
|
+
const length2 = beam.stations[i + 1] - beam.stations[i];
|
|
25521
|
+
const k = toObjectFrame(beamLocal(section, length2), 12, beam.axis, beam.u, beam.v);
|
|
25522
|
+
elements.push({ dofs: [...dofsOf(beam.nodes[i]), ...dofsOf(beam.nodes[i + 1])], k, parts: [beam.part.id] });
|
|
25523
|
+
}
|
|
25524
|
+
}
|
|
25525
|
+
for (const [joint2, stations] of stationed) {
|
|
25526
|
+
const a = beams.get(joint2.a);
|
|
25527
|
+
const b = beams.get(joint2.b);
|
|
25528
|
+
for (const s of stations) {
|
|
25529
|
+
const na = nearest(a, s.at);
|
|
25530
|
+
const nb = nearest(b, s.at);
|
|
25531
|
+
const ra = armRows(vec.sub(s.at, nodes[na].at));
|
|
25532
|
+
const rb = armRows(vec.sub(s.at, nodes[nb].at));
|
|
25533
|
+
const rows = [];
|
|
25534
|
+
for (let i = 0; i < 3; i++) rows.push([...ra[i].map((x) => -x), ...rb[i]]);
|
|
25535
|
+
for (let i = 0; i < 3; i++) {
|
|
25536
|
+
const row = new Array(12).fill(0);
|
|
25537
|
+
row[3 + i] = -1;
|
|
25538
|
+
row[9 + i] = 1;
|
|
25539
|
+
rows.push(row);
|
|
25540
|
+
}
|
|
25541
|
+
const k = new Float64Array(144);
|
|
25542
|
+
for (let axis2 = 0; axis2 < 3; axis2++) {
|
|
25543
|
+
const e = s.frame[axis2];
|
|
25544
|
+
for (const [stiffness, base2] of [[s.push[axis2], 0], [s.turn[axis2], 3]]) {
|
|
25545
|
+
if (stiffness === 0) continue;
|
|
25546
|
+
const b12 = new Array(12).fill(0);
|
|
25547
|
+
for (let i = 0; i < 3; i++) for (let m = 0; m < 12; m++) b12[m] = b12[m] + e[i] * rows[base2 + i][m];
|
|
25548
|
+
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];
|
|
25549
|
+
}
|
|
25550
|
+
}
|
|
25551
|
+
elements.push({ dofs: [...dofsOf(na), ...dofsOf(nb)], k, parts: [joint2.a, joint2.b] });
|
|
25552
|
+
}
|
|
25553
|
+
}
|
|
25554
|
+
const supports = [];
|
|
25555
|
+
for (const [id, corners] of footPoints) {
|
|
25556
|
+
const beam = beams.get(id);
|
|
25557
|
+
for (const at4 of corners) {
|
|
25558
|
+
const node = nearest(beam, at4);
|
|
25559
|
+
supports.push({ part: id, node, arm: vec.sub(at4, nodes[node].at), at: at4 });
|
|
25560
|
+
}
|
|
25561
|
+
}
|
|
25562
|
+
const frame2 = { nodes, beams, elements, supports, order: order2 };
|
|
25563
|
+
const before = lost.size > 0 ? solveFrame(frame2, input, joints, structural, /* @__PURE__ */ new Set(), g, null) : null;
|
|
25564
|
+
const after2 = solveFrame(frame2, input, joints, structural, lost, g, before);
|
|
25565
|
+
if (!after2) return null;
|
|
25566
|
+
let mass = 0;
|
|
25567
|
+
const centre = [0, 0, 0];
|
|
25568
|
+
const shift = [0, 0, 0];
|
|
25569
|
+
let all = 0;
|
|
25570
|
+
const allCentre = [0, 0, 0];
|
|
25571
|
+
const moved = (s, point) => {
|
|
25572
|
+
const base2 = order2[point.node] * 6;
|
|
25573
|
+
const theta = [s.u[base2 + 3], s.u[base2 + 4], s.u[base2 + 5]];
|
|
25574
|
+
return vec.add([s.u[base2], s.u[base2 + 1], s.u[base2 + 2]], vec.cross(theta, point.arm));
|
|
25575
|
+
};
|
|
25576
|
+
for (const p of after2.masses) {
|
|
25577
|
+
const at4 = vec.add(nodes[p.node].at, p.arm);
|
|
25578
|
+
const by = moved(after2, p);
|
|
25579
|
+
all += p.mass;
|
|
25580
|
+
for (let k = 0; k < 3; k++) allCentre[k] = allCentre[k] + (at4[k] + by[k]) * p.mass;
|
|
25581
|
+
if (p.part === null) continue;
|
|
25582
|
+
mass += p.mass;
|
|
25583
|
+
for (let k = 0; k < 3; k++) {
|
|
25584
|
+
centre[k] = centre[k] + at4[k] * p.mass;
|
|
25585
|
+
shift[k] = shift[k] + by[k] * p.mass;
|
|
25586
|
+
}
|
|
25587
|
+
}
|
|
25588
|
+
if (mass <= 0) return null;
|
|
25589
|
+
for (let k = 0; k < 3; k++) {
|
|
25590
|
+
centre[k] = centre[k] / mass;
|
|
25591
|
+
shift[k] = shift[k] / mass;
|
|
25592
|
+
allCentre[k] = allCentre[k] / all;
|
|
25593
|
+
}
|
|
25594
|
+
const feet = after2.holding.map((s) => s.at);
|
|
25595
|
+
let released = 0;
|
|
25596
|
+
let spin = null;
|
|
25597
|
+
if (before) {
|
|
25598
|
+
const n = nodes.length * 6;
|
|
25599
|
+
const delta = new Float64Array(n);
|
|
25600
|
+
for (let i = 0; i < n; i++) delta[i] = after2.u[i] - before.u[i];
|
|
25601
|
+
for (const beam of beams.values()) if (!after2.standing.has(beam.part.id)) for (const node of beam.nodes) for (const dof of dofsOf(node)) delta[dof] = 0;
|
|
25602
|
+
for (let i = 0; i < n; i++) {
|
|
25603
|
+
if (delta[i] === 0) continue;
|
|
25604
|
+
let row = 0;
|
|
25605
|
+
for (let j = 0; j < n; j++) row += after2.k[i * n + j] * delta[j];
|
|
25606
|
+
released += 0.5 * delta[i] * row;
|
|
25607
|
+
}
|
|
25608
|
+
spin = spinOf({ frame: frame2, after: after2, delta, released, centre: allCentre, mass: all, floor: floor2, g });
|
|
25609
|
+
}
|
|
25610
|
+
return {
|
|
25611
|
+
mass,
|
|
25612
|
+
centre,
|
|
25613
|
+
shift,
|
|
25614
|
+
released,
|
|
25615
|
+
spin,
|
|
25616
|
+
feet,
|
|
25617
|
+
deflection(id, point) {
|
|
25618
|
+
const beam = beams.get(id);
|
|
25619
|
+
if (!beam || !after2.standing.has(id)) return null;
|
|
25620
|
+
const node = nearest(beam, point);
|
|
25621
|
+
return moved(after2, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 });
|
|
25622
|
+
}
|
|
25623
|
+
};
|
|
25624
|
+
}
|
|
25625
|
+
function standingParts(frame2, joints, structural, gone) {
|
|
25626
|
+
const standing = /* @__PURE__ */ new Set();
|
|
25627
|
+
const queue = [];
|
|
25628
|
+
for (const s of frame2.supports) {
|
|
25629
|
+
if (gone.has(s.part) || standing.has(s.part)) continue;
|
|
25630
|
+
standing.add(s.part);
|
|
25631
|
+
queue.push(s.part);
|
|
25632
|
+
}
|
|
25633
|
+
while (queue.length > 0) {
|
|
25634
|
+
const id = queue.pop();
|
|
25635
|
+
for (const j of joints) {
|
|
25636
|
+
if (!structural(j) || j.a !== id && j.b !== id) continue;
|
|
25637
|
+
const other = j.a === id ? j.b : j.a;
|
|
25638
|
+
if (gone.has(other) || standing.has(other)) continue;
|
|
25639
|
+
standing.add(other);
|
|
25640
|
+
queue.push(other);
|
|
25641
|
+
}
|
|
25642
|
+
}
|
|
25643
|
+
return standing;
|
|
25644
|
+
}
|
|
25645
|
+
function solveFrame(frame2, input, joints, structural, gone, g, from) {
|
|
25646
|
+
const { nodes, beams, order: order2 } = frame2;
|
|
25647
|
+
const n = nodes.length * 6;
|
|
25648
|
+
const standing = standingParts(frame2, joints, structural, gone);
|
|
25649
|
+
if (standing.size === 0) return null;
|
|
25650
|
+
const nearestNode = (p, among) => {
|
|
25651
|
+
let best = -1;
|
|
25652
|
+
let bestDistance = Infinity;
|
|
25653
|
+
for (const id of among) {
|
|
25654
|
+
const beam = beams.get(id);
|
|
25655
|
+
for (const node of beam.nodes) {
|
|
25656
|
+
const d = vec.distance(nodes[node].at, p);
|
|
25657
|
+
if (d < bestDistance) {
|
|
25658
|
+
bestDistance = d;
|
|
25659
|
+
best = node;
|
|
25660
|
+
}
|
|
25661
|
+
}
|
|
25662
|
+
}
|
|
25663
|
+
return best;
|
|
25664
|
+
};
|
|
25665
|
+
const masses = [];
|
|
25666
|
+
for (const id of standing) {
|
|
25667
|
+
const beam = beams.get(id);
|
|
25668
|
+
const perMetre = beam.part.mass / beam.length;
|
|
25669
|
+
for (let i = 0; i < beam.nodes.length; i++) {
|
|
25670
|
+
const before = i > 0 ? beam.stations[i] - beam.stations[i - 1] : 0;
|
|
25671
|
+
const next = i + 1 < beam.nodes.length ? beam.stations[i + 1] - beam.stations[i] : 0;
|
|
25672
|
+
masses.push({ part: id, node: beam.nodes[i], arm: [0, 0, 0], mass: perMetre * (before + next) / 2 });
|
|
25673
|
+
}
|
|
25674
|
+
}
|
|
25675
|
+
const carried = /* @__PURE__ */ new Map();
|
|
25676
|
+
let grew = true;
|
|
25677
|
+
while (grew) {
|
|
25678
|
+
grew = false;
|
|
25679
|
+
for (const j of joints) {
|
|
25680
|
+
for (const [id, host] of [[j.a, j.b], [j.b, j.a]]) {
|
|
25681
|
+
if (gone.has(id) || gone.has(host) || standing.has(id) || carried.has(id)) continue;
|
|
25682
|
+
if (!standing.has(host) && !carried.has(host)) continue;
|
|
25683
|
+
carried.set(id, standing.has(host) ? host : carried.get(host));
|
|
25684
|
+
grew = true;
|
|
25685
|
+
}
|
|
25686
|
+
}
|
|
25687
|
+
}
|
|
25688
|
+
for (const [id, host] of carried) {
|
|
25689
|
+
const part = beams.get(id).part;
|
|
25690
|
+
const node = nearestNode(part.position, [host]);
|
|
25691
|
+
masses.push({ part: id, node, arm: vec.sub(part.position, nodes[node].at), mass: part.mass });
|
|
25692
|
+
}
|
|
25693
|
+
for (const load of input.loads ?? []) {
|
|
25694
|
+
if (load.mass <= 0) continue;
|
|
25695
|
+
const node = nearestNode(load.position, standing);
|
|
25696
|
+
masses.push({ part: null, node, arm: vec.sub(load.position, nodes[node].at), mass: load.mass });
|
|
25697
|
+
}
|
|
25698
|
+
const f = new Float64Array(n);
|
|
25699
|
+
for (const p of masses) {
|
|
25700
|
+
const base2 = order2[p.node] * 6;
|
|
25701
|
+
const weight = -p.mass * g;
|
|
25702
|
+
f[base2 + 1] = f[base2 + 1] + weight;
|
|
25703
|
+
f[base2 + 3] = f[base2 + 3] - p.arm[2] * weight;
|
|
25704
|
+
f[base2 + 5] = f[base2 + 5] + p.arm[0] * weight;
|
|
25705
|
+
}
|
|
25706
|
+
const structure = new Float64Array(n * n);
|
|
25707
|
+
let largest = 0;
|
|
25708
|
+
for (const element of frame2.elements) {
|
|
25709
|
+
if (!element.parts.every((id) => standing.has(id))) continue;
|
|
25710
|
+
const size = element.dofs.length;
|
|
25711
|
+
for (let p = 0; p < size; p++) {
|
|
25712
|
+
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];
|
|
25713
|
+
}
|
|
25714
|
+
}
|
|
25715
|
+
for (let i = 0; i < n; i++) largest = Math.max(largest, structure[i * n + i]);
|
|
25716
|
+
if (largest <= 0) return null;
|
|
25717
|
+
const free = new Uint8Array(n);
|
|
25718
|
+
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;
|
|
25719
|
+
for (let i = 0; i < n; i++) {
|
|
25720
|
+
if (!free[i]) {
|
|
25721
|
+
structure[i * n + i] = largest;
|
|
25722
|
+
f[i] = 0;
|
|
25723
|
+
} else structure[i * n + i] = structure[i * n + i] + largest * SOFT;
|
|
25724
|
+
}
|
|
25725
|
+
const feet = frame2.supports.filter((s) => standing.has(s.part));
|
|
25726
|
+
const holds3 = feet.map((s) => !from || from.holding.includes(s));
|
|
25727
|
+
const footed = [...new Set(feet.map((s) => s.part))];
|
|
25728
|
+
const grips = new Map(footed.map((id) => [id, true]));
|
|
25729
|
+
const friction = input.friction ?? FOOT_FRICTION;
|
|
25730
|
+
const k = new Float64Array(n * n);
|
|
25731
|
+
const u = new Float64Array(n);
|
|
25732
|
+
const build = () => {
|
|
25733
|
+
k.set(structure);
|
|
25734
|
+
const held = /* @__PURE__ */ new Map();
|
|
25735
|
+
feet.forEach((s, index) => {
|
|
25736
|
+
if (!holds3[index]) return;
|
|
25737
|
+
const row = armRows(s.arm)[1];
|
|
25738
|
+
const base2 = order2[s.node] * 6;
|
|
25739
|
+
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];
|
|
25740
|
+
held.set(s.part, [...held.get(s.part) ?? [], s]);
|
|
25741
|
+
});
|
|
25742
|
+
for (const [id, points] of held) {
|
|
25743
|
+
const { node, arm } = gripOf(points);
|
|
25744
|
+
const upright = order2[node] * 6 + 4;
|
|
25745
|
+
k[upright * n + upright] = k[upright * n + upright] + RIGID_TURN;
|
|
25746
|
+
if (!grips.get(id)) continue;
|
|
25747
|
+
const rows = armRows(arm);
|
|
25748
|
+
const base2 = order2[node] * 6;
|
|
25749
|
+
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];
|
|
25750
|
+
}
|
|
25751
|
+
};
|
|
25752
|
+
const liftOf = (s) => {
|
|
25753
|
+
const base2 = order2[s.node] * 6;
|
|
25754
|
+
return u[base2 + 1] + (u[base2 + 5] * s.arm[0] - u[base2 + 3] * s.arm[2]);
|
|
25755
|
+
};
|
|
25756
|
+
const rounds = 4 * feet.length + 2 * footed.length + 4;
|
|
25757
|
+
for (let round5 = 0; round5 < rounds; round5++) {
|
|
25758
|
+
build();
|
|
25759
|
+
u.set(f);
|
|
25760
|
+
if (!solve(k, u, n)) return null;
|
|
25761
|
+
const pull = 1e-12;
|
|
25762
|
+
const sink = -1e-9;
|
|
25763
|
+
if (round5 === 0) {
|
|
25764
|
+
let any = false;
|
|
25765
|
+
feet.forEach((s, index) => {
|
|
25766
|
+
if (!holds3[index] || liftOf(s) <= pull) return;
|
|
25767
|
+
holds3[index] = false;
|
|
25768
|
+
any = true;
|
|
25769
|
+
});
|
|
25770
|
+
if (any) continue;
|
|
25771
|
+
}
|
|
25772
|
+
const worstOf = /* @__PURE__ */ new Map();
|
|
25773
|
+
feet.forEach((s, index) => {
|
|
25774
|
+
const lift = liftOf(s);
|
|
25775
|
+
const pulls = holds3[index] && lift > pull;
|
|
25776
|
+
if (!pulls && !(!holds3[index] && lift < sink)) return;
|
|
25777
|
+
const key2 = round5 < rounds / 2 ? s.part : "";
|
|
25778
|
+
const by = Math.abs(lift);
|
|
25779
|
+
const now = worstOf.get(key2);
|
|
25780
|
+
if (!now || pulls && !now.pulls || pulls === now.pulls && by > now.by) worstOf.set(key2, { index, by, pulls });
|
|
25781
|
+
});
|
|
25782
|
+
if (worstOf.size > 0) {
|
|
25783
|
+
for (const change of worstOf.values()) holds3[change.index] = !change.pulls;
|
|
25784
|
+
continue;
|
|
25785
|
+
}
|
|
25786
|
+
let slides = null;
|
|
25787
|
+
let over = 1;
|
|
25788
|
+
let gripping = 0;
|
|
25789
|
+
for (const id of footed) {
|
|
25790
|
+
const points = feet.filter((s, index) => s.part === id && holds3[index]);
|
|
25791
|
+
if (points.length === 0 || !grips.get(id)) continue;
|
|
25792
|
+
gripping++;
|
|
25793
|
+
let weight = 0;
|
|
25794
|
+
for (const s of points) weight += -RIGID_PUSH * liftOf(s);
|
|
25795
|
+
const { node, arm } = gripOf(points);
|
|
25796
|
+
const base2 = order2[node] * 6;
|
|
25797
|
+
const x = u[base2] + (u[base2 + 4] * arm[2] - u[base2 + 5] * arm[1]);
|
|
25798
|
+
const z = u[base2 + 2] + (u[base2 + 3] * arm[1] - u[base2 + 4] * arm[0]);
|
|
25799
|
+
const ratio = RIGID_PUSH * Math.hypot(x, z) / Math.max(friction * weight, 1e-9);
|
|
25800
|
+
if (ratio > over) {
|
|
25801
|
+
over = ratio;
|
|
25802
|
+
slides = id;
|
|
25803
|
+
}
|
|
25804
|
+
}
|
|
25805
|
+
if (slides !== null && gripping > 1) {
|
|
25806
|
+
grips.set(slides, false);
|
|
25807
|
+
continue;
|
|
25808
|
+
}
|
|
25809
|
+
let worst = 0;
|
|
25810
|
+
for (let i = 0; i < n; i++) if (free[i]) worst = Math.max(worst, Math.abs(u[i]));
|
|
25811
|
+
if (worst > MECHANISM) return null;
|
|
25812
|
+
const holding = feet.filter((_, index) => holds3[index]);
|
|
25813
|
+
if (holding.length < 3) return null;
|
|
25814
|
+
build();
|
|
25815
|
+
return { u: u.slice(), k: k.slice(), holding, masses, standing };
|
|
25816
|
+
}
|
|
25817
|
+
return null;
|
|
25818
|
+
}
|
|
25819
|
+
function gripOf(points) {
|
|
25820
|
+
const first = points[0];
|
|
25821
|
+
let arm = [0, 0, 0];
|
|
25822
|
+
for (const s of points) arm = vec.add(arm, vec.sub(s.at, vec.sub(first.at, first.arm)));
|
|
25823
|
+
return { node: first.node, arm: vec.scale(arm, 1 / points.length) };
|
|
25824
|
+
}
|
|
25825
|
+
function spinOf(input) {
|
|
25826
|
+
const { frame: frame2, after: after2, delta, released, centre, mass, floor: floor2, g } = input;
|
|
25827
|
+
if (!(released > 0)) return null;
|
|
25828
|
+
const { nodes, order: order2 } = frame2;
|
|
25829
|
+
const points = after2.masses.map((p) => {
|
|
25830
|
+
const base2 = order2[p.node] * 6;
|
|
25831
|
+
const theta = [delta[base2 + 3], delta[base2 + 4], delta[base2 + 5]];
|
|
25832
|
+
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 };
|
|
25833
|
+
});
|
|
25834
|
+
let moving = 0;
|
|
25835
|
+
for (const p of points) moving += p.mass * vec.dot(p.by, p.by);
|
|
25836
|
+
if (!(moving > 0)) return null;
|
|
25837
|
+
const scale = Math.sqrt(2 * released / moving);
|
|
25838
|
+
const hull = hullOf(after2.holding.map((s) => [s.at[0], s.at[2]]));
|
|
25839
|
+
if (hull.length < 3) return null;
|
|
25840
|
+
let best = null;
|
|
25841
|
+
for (let i = 0; i < hull.length; i++) {
|
|
25842
|
+
const p = hull[i];
|
|
25843
|
+
const q = hull[(i + 1) % hull.length];
|
|
25844
|
+
const length2 = Math.hypot(q[0] - p[0], q[1] - p[1]);
|
|
25845
|
+
if (length2 < 1e-9) continue;
|
|
25846
|
+
const point = [p[0], floor2, p[1]];
|
|
25847
|
+
let axis2 = [(q[0] - p[0]) / length2, 0, (q[1] - p[1]) / length2];
|
|
25848
|
+
const inward = [centre[0] - point[0], 0, centre[2] - point[2]];
|
|
25849
|
+
let out = vec.cross(axis2, [0, 1, 0]);
|
|
25850
|
+
if (vec.dot(out, inward) > 0) {
|
|
25851
|
+
axis2 = vec.scale(axis2, -1);
|
|
25852
|
+
out = vec.scale(out, -1);
|
|
25853
|
+
}
|
|
25854
|
+
const depth = -vec.dot(out, inward);
|
|
25855
|
+
let momentum = 0;
|
|
25856
|
+
let inertia = 0;
|
|
25857
|
+
for (const m of points) {
|
|
25858
|
+
const r = vec.sub(m.at, point);
|
|
25859
|
+
const off = vec.sub(r, vec.scale(axis2, vec.dot(r, axis2)));
|
|
25860
|
+
momentum += m.mass * vec.dot(vec.cross(r, vec.scale(m.by, scale)), axis2);
|
|
25861
|
+
inertia += m.mass * vec.dot(off, off);
|
|
25862
|
+
}
|
|
25863
|
+
if (!(inertia > 0)) continue;
|
|
25864
|
+
const rate = momentum / inertia;
|
|
25865
|
+
if (!(rate > 0)) continue;
|
|
25866
|
+
const height = centre[1] - floor2;
|
|
25867
|
+
const barrier = depth > 0 ? mass * g * (Math.hypot(height, depth) - height) : 0;
|
|
25868
|
+
const energy = 0.5 * inertia * rate * rate;
|
|
25869
|
+
const margin = energy - barrier;
|
|
25870
|
+
if (!best || margin > best.margin) best = { point, axis: axis2, rate, margin, energy, barrier };
|
|
25871
|
+
}
|
|
25872
|
+
return best ? { point: best.point, axis: best.axis, rate: best.rate, energy: best.energy, barrier: best.barrier } : null;
|
|
25873
|
+
}
|
|
25019
25874
|
var SWEEP_BROAD_SLACK = 1e-3;
|
|
25020
25875
|
var sweptBounds = (origins, direction, length2) => {
|
|
25021
25876
|
if (origins.length === 0 || !Number.isFinite(length2)) return null;
|
|
@@ -25112,6 +25967,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25112
25967
|
return { ...base2, mesh: { vertices, indices: piece3.mesh.indices } };
|
|
25113
25968
|
};
|
|
25114
25969
|
var THIN_SHEET_DISHING = 5e-3;
|
|
25970
|
+
var TEAR_CALIBERS = 1.1;
|
|
25115
25971
|
var SHELL_YIELD_SHARE = 0.5;
|
|
25116
25972
|
var STEEL_YIELD_MPA = 250;
|
|
25117
25973
|
var SWEEP_BACK = 0.01;
|
|
@@ -25204,7 +26060,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25204
26060
|
var MAX_PLASTER_FLAKES = 24;
|
|
25205
26061
|
var CHIP_ENERGY = 200;
|
|
25206
26062
|
var CHIP_SPLASH = 0.5;
|
|
26063
|
+
var SHARD_CUT = [0.3, 0.7];
|
|
26064
|
+
var MORTAR_JOINT = 0.01;
|
|
26065
|
+
var MIN_UNIT_SHARE = 0.8;
|
|
26066
|
+
var CHIP_DRIVE = 0.6;
|
|
26067
|
+
var BLAST_DRIVE = 2.5;
|
|
25207
26068
|
var CRATER_SPENT = 0.6;
|
|
26069
|
+
var BONDING_JOINTS = /* @__PURE__ */ new Set(["glue", "mortar", "nail", "screw"]);
|
|
26070
|
+
var PLATE_ASPECT = 0.25;
|
|
26071
|
+
var PLATE_BACK_SHARE = 0.5;
|
|
26072
|
+
var BONDED_REMNANT = 0.25;
|
|
25208
26073
|
var EDGE_REACH = 1.5;
|
|
25209
26074
|
var BAR_BOW = 0.08;
|
|
25210
26075
|
var BULLET_JOINT_SPAN = 0.3;
|
|
@@ -25235,9 +26100,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25235
26100
|
};
|
|
25236
26101
|
var BURIED_BLAST_REACH = 0.5;
|
|
25237
26102
|
var GIVE_AT_CUT_HP = 0.5;
|
|
26103
|
+
var lineToSegment = (o, d, a, b) => {
|
|
26104
|
+
const ab = vec.sub(b, a);
|
|
26105
|
+
const ao = vec.sub(a, o);
|
|
26106
|
+
const abab = vec.dot(ab, ab);
|
|
26107
|
+
const abd = vec.dot(ab, d);
|
|
26108
|
+
const denom = abab - abd * abd;
|
|
26109
|
+
if (abab < 1e-12) return null;
|
|
26110
|
+
if (denom < 1e-12) {
|
|
26111
|
+
const end3 = vec.dot(ao, d) <= vec.dot(vec.sub(b, o), d) ? a : b;
|
|
26112
|
+
return { point: end3, distance: vec.distance(end3, vec.madd(o, d, vec.dot(vec.sub(end3, o), d))) };
|
|
26113
|
+
}
|
|
26114
|
+
const s = clamp2((abd * vec.dot(ao, d) - vec.dot(ao, ab)) / denom, 0, 1);
|
|
26115
|
+
const point = vec.madd(a, ab, s);
|
|
26116
|
+
const t = vec.dot(vec.sub(point, o), d);
|
|
26117
|
+
return { point, distance: vec.distance(point, vec.madd(o, d, t)) };
|
|
26118
|
+
};
|
|
26119
|
+
var cageLeft = (p) => {
|
|
26120
|
+
const r = p.spec.reinforcement;
|
|
26121
|
+
if (!r) return 1;
|
|
26122
|
+
const total = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length;
|
|
26123
|
+
return total > 0 ? Math.max(0, total - (p.rt.severedBars?.length ?? 0)) / total : 1;
|
|
26124
|
+
};
|
|
25238
26125
|
var capacityScale = (p, borne, through) => {
|
|
25239
26126
|
const residual = p.spec.reinforcement?.residualCapacity ?? RESIDUAL_CAPACITY;
|
|
25240
|
-
if (p.st.stripped) return residual;
|
|
26127
|
+
if (p.st.stripped) return residual * cageLeft(p);
|
|
25241
26128
|
const kept = Math.min(p.rt.removed ? 1 - p.rt.removed / p.mass0 : 1, sectionKept(p, residual, borne, through));
|
|
25242
26129
|
return Math.max(p.spec.reinforcement ? residual : 0.05, kept);
|
|
25243
26130
|
};
|
|
@@ -25312,6 +26199,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25312
26199
|
};
|
|
25313
26200
|
var HOSTED_TOLERANCE = 0.02;
|
|
25314
26201
|
var HOLE_SLACK = 0.05;
|
|
26202
|
+
var GRAIN_AXIS = { x: 0, y: 1, z: 2 };
|
|
25315
26203
|
var isLost = (p) => p.st.status === "broken" || p.st.status === "melted" || p.st.status === "ashes";
|
|
25316
26204
|
var clone = (v) => structuredClone(v);
|
|
25317
26205
|
var overloadRate = (stress) => Math.min(0.6, 0.12 + 0.8 * (stress - 1));
|
|
@@ -25886,7 +26774,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25886
26774
|
byKey.set(key2, span);
|
|
25887
26775
|
return span;
|
|
25888
26776
|
};
|
|
25889
|
-
const
|
|
26777
|
+
const sectionOf22 = (p, axis2) => {
|
|
25890
26778
|
const g = p.bend;
|
|
25891
26779
|
const section = { b: sectionWidth(g, axis2), h: g.dims[axis2] };
|
|
25892
26780
|
const rebar2 = tensionSteel(p.spec, g.dims, section, flexure);
|
|
@@ -25901,7 +26789,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25901
26789
|
}
|
|
25902
26790
|
p.restMoment = 0;
|
|
25903
26791
|
if (g.gravity < 0 || p.span <= 0) return 0;
|
|
25904
|
-
const sec =
|
|
26792
|
+
const sec = sectionOf22(p, g.gravity);
|
|
25905
26793
|
p.restMoment = spanMoment(lineLoad(g, p.bendLoad) * Math.abs(g.up[g.gravity]), p.span);
|
|
25906
26794
|
const holds3 = (p.st.cracked ? sec.steel : sec.ultimate) * capacityScale(p);
|
|
25907
26795
|
return p.restMoment * structureSafety / Math.max(holds3, 1);
|
|
@@ -25936,7 +26824,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25936
26824
|
const impulse = sum2 / offsets.length * cos2 * reach2 * width * L;
|
|
25937
26825
|
const weight = axis2 === g.gravity ? p.bendLoad : p.st.mass;
|
|
25938
26826
|
const kinetic = impulseEnergy(impulse, lineLoad(g, weight) / GRAVITY * L, flexure);
|
|
25939
|
-
const sec =
|
|
26827
|
+
const sec = sectionOf22(p, axis2);
|
|
25940
26828
|
const EI = s.elasticGPa * 1e9 * sec.section.b * sec.section.h ** 3 / 12;
|
|
25941
26829
|
const along2 = axis2 === g.gravity ? -Math.sign(away[axis2] * g.up[axis2]) : 0;
|
|
25942
26830
|
const dynamic2 = momentOfEnergy(kinetic, L, EI, flexure.loadFactor);
|
|
@@ -26080,7 +26968,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26080
26968
|
p.bendLoad = p.st.mass + bending[i];
|
|
26081
26969
|
const bent = restFlexure(o, p, lowerOf(i));
|
|
26082
26970
|
p.st.flexure = bent;
|
|
26083
|
-
p.snap = bent > 1 && !p.st.stripped && !
|
|
26971
|
+
p.snap = bent > 1 && !p.st.stripped && !sectionOf22(p, p.bend.gravity).reinforced;
|
|
26084
26972
|
if (p.spec.structure?.capacity === void 0 || bent > p.st.stress) p.st.stress = bent;
|
|
26085
26973
|
}
|
|
26086
26974
|
if (p.st.stress > o.maxStress) o.maxStress = p.st.stress;
|
|
@@ -27111,11 +27999,56 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27111
27999
|
return r ? { t0: r.t0, t1: r.t1, n: rotateVec(q, r.n0) } : null;
|
|
27112
28000
|
};
|
|
27113
28001
|
const rayPart = (o, p, origin, d) => rayPartRaw(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
|
|
28002
|
+
const rayCentre = [0, 0, 0];
|
|
28003
|
+
const rayTurn = [0, 0, 0, 1];
|
|
28004
|
+
const rayTurnBack = [0, 0, 0, 1];
|
|
28005
|
+
const rayOrigin = [0, 0, 0];
|
|
28006
|
+
const rayDirection = [0, 0, 0];
|
|
28007
|
+
const rayShapeHit = { t0: 0, t1: 0, n0: [0, 0, 0] };
|
|
28008
|
+
const rayHitNormal = [0, 0, 0];
|
|
28009
|
+
const rayHit = { t0: 0, t1: 0, n: rayHitNormal };
|
|
28010
|
+
const rayPartInto = (pos, rot, spec, pq, origin, d, lp) => {
|
|
28011
|
+
rotateVecInto(rot, lp, rayCentre);
|
|
28012
|
+
rayCentre[0] += pos[0];
|
|
28013
|
+
rayCentre[1] += pos[1];
|
|
28014
|
+
rayCentre[2] += pos[2];
|
|
28015
|
+
rayTurn[0] = rot[3] * pq[0] + rot[0] * pq[3] + rot[1] * pq[2] - rot[2] * pq[1];
|
|
28016
|
+
rayTurn[1] = rot[3] * pq[1] - rot[0] * pq[2] + rot[1] * pq[3] + rot[2] * pq[0];
|
|
28017
|
+
rayTurn[2] = rot[3] * pq[2] + rot[0] * pq[1] - rot[1] * pq[0] + rot[2] * pq[3];
|
|
28018
|
+
rayTurn[3] = rot[3] * pq[3] - rot[0] * pq[0] - rot[1] * pq[1] - rot[2] * pq[2];
|
|
28019
|
+
rayTurnBack[0] = -rayTurn[0];
|
|
28020
|
+
rayTurnBack[1] = -rayTurn[1];
|
|
28021
|
+
rayTurnBack[2] = -rayTurn[2];
|
|
28022
|
+
rayTurnBack[3] = rayTurn[3];
|
|
28023
|
+
rayOrigin[0] = origin[0] - rayCentre[0];
|
|
28024
|
+
rayOrigin[1] = origin[1] - rayCentre[1];
|
|
28025
|
+
rayOrigin[2] = origin[2] - rayCentre[2];
|
|
28026
|
+
rotateVecInto(rayTurnBack, rayOrigin, rayOrigin);
|
|
28027
|
+
rotateVecInto(rayTurnBack, d, rayDirection);
|
|
28028
|
+
if (!rayShapeInto(spec.shape, rayOrigin, rayDirection, rayShapeHit)) return null;
|
|
28029
|
+
rayHit.t0 = rayShapeHit.t0;
|
|
28030
|
+
rayHit.t1 = rayShapeHit.t1;
|
|
28031
|
+
rayHit.n = rotateVecInto(rayTurn, rayShapeHit.n0, rayHitNormal);
|
|
28032
|
+
return rayHit;
|
|
28033
|
+
};
|
|
28034
|
+
const specTurns = /* @__PURE__ */ new WeakMap();
|
|
28035
|
+
const specTurnOf = (ps) => {
|
|
28036
|
+
let turn2 = specTurns.get(ps);
|
|
28037
|
+
if (!turn2) {
|
|
28038
|
+
turn2 = quatFromEuler2(...ps.rotation ?? [0, 0, 0]);
|
|
28039
|
+
specTurns.set(ps, turn2);
|
|
28040
|
+
}
|
|
28041
|
+
return turn2;
|
|
28042
|
+
};
|
|
28043
|
+
const copyOf2 = (v) => [v[0], v[1], v[2]];
|
|
28044
|
+
const objectTurnBack = [0, 0, 0, 1];
|
|
28045
|
+
const objectOrigin = [0, 0, 0];
|
|
28046
|
+
const objectDirection = [0, 0, 0];
|
|
27114
28047
|
const PART_BOUND_SLACK = 1e-6;
|
|
27115
28048
|
const raySphereMiss = (origin, d, c, r, maxDist) => {
|
|
27116
|
-
const
|
|
27117
|
-
const b =
|
|
27118
|
-
const cc =
|
|
28049
|
+
const ox = origin[0] - c[0], oy = origin[1] - c[1], oz = origin[2] - c[2];
|
|
28050
|
+
const b = ox * d[0] + oy * d[1] + oz * d[2];
|
|
28051
|
+
const cc = ox * ox + oy * oy + oz * oz - r * r;
|
|
27119
28052
|
if (cc > 0 && b > 0) return true;
|
|
27120
28053
|
const disc = b * b - cc;
|
|
27121
28054
|
if (disc < 0) return true;
|
|
@@ -27308,9 +28241,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27308
28241
|
if (skip.skipLoose && o.loose || o.br < minRadius) continue;
|
|
27309
28242
|
if (outside && !outside.mayMeet(o.id)) continue;
|
|
27310
28243
|
if (raySphereMiss(origin, d, worldCentreOf(o), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
|
|
27311
|
-
const
|
|
27312
|
-
|
|
27313
|
-
|
|
28244
|
+
const turn2 = o.st.rotation;
|
|
28245
|
+
objectTurnBack[0] = -turn2[0];
|
|
28246
|
+
objectTurnBack[1] = -turn2[1];
|
|
28247
|
+
objectTurnBack[2] = -turn2[2];
|
|
28248
|
+
objectTurnBack[3] = turn2[3];
|
|
28249
|
+
objectOrigin[0] = origin[0] - o.st.position[0];
|
|
28250
|
+
objectOrigin[1] = origin[1] - o.st.position[1];
|
|
28251
|
+
objectOrigin[2] = origin[2] - o.st.position[2];
|
|
28252
|
+
const lo = rotateVecInto(objectTurnBack, objectOrigin, objectOrigin);
|
|
28253
|
+
const ld = rotateVecInto(objectTurnBack, d, objectDirection);
|
|
27314
28254
|
for (const p of scope2?.parts.get(o) ?? (counts ? o.parts : partsAlong(o, lo, ld, maxDist))) {
|
|
27315
28255
|
if (counts) counts.partVisits++;
|
|
27316
28256
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
@@ -27319,15 +28259,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27319
28259
|
counts.shapeTests++;
|
|
27320
28260
|
counts.shapeTested.add(o.id);
|
|
27321
28261
|
}
|
|
27322
|
-
const r =
|
|
28262
|
+
const r = rayPartInto(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
|
|
28263
|
+
if (r && r.t0 < 0 && r.t1 > 0 && p.st.chipped?.length && inGap(p, toLocal(p.pos, p.q, objLocal(o, origin)))) {
|
|
28264
|
+
r.t0 = 0;
|
|
28265
|
+
r.n = vec.scale(d, -1);
|
|
28266
|
+
}
|
|
27323
28267
|
if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
|
|
27324
28268
|
if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
27325
28269
|
if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
27326
|
-
|
|
27327
|
-
|
|
27328
|
-
|
|
28270
|
+
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))));
|
|
28271
|
+
if (cutBand) {
|
|
28272
|
+
if (passed) {
|
|
28273
|
+
passed.push({ o, p, t: r.t0 });
|
|
28274
|
+
continue;
|
|
28275
|
+
}
|
|
28276
|
+
const bar2 = skip.body ? barAlong(o, p, origin, d, r.t0, r.t1) : null;
|
|
28277
|
+
if (bar2 === null) continue;
|
|
28278
|
+
r.t0 = bar2;
|
|
28279
|
+
r.n = vec.scale(d, -1);
|
|
27329
28280
|
}
|
|
27330
|
-
const
|
|
28281
|
+
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;
|
|
28282
|
+
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;
|
|
27331
28283
|
if (gap === "through") continue;
|
|
27332
28284
|
if (gap) {
|
|
27333
28285
|
r.t0 = gap.t;
|
|
@@ -27342,8 +28294,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27342
28294
|
}
|
|
27343
28295
|
if (!best || r.t0 < best.distance) {
|
|
27344
28296
|
const point = vec.madd(origin, d, r.t0);
|
|
27345
|
-
const
|
|
27346
|
-
|
|
28297
|
+
const normal = copyOf2(r.n);
|
|
28298
|
+
const member = p.castIn ? castMemberAt(o, { p, point, normal, dir: d, pathLen: r.t1 - r.t0 }, origin, d) : null;
|
|
28299
|
+
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 };
|
|
27347
28300
|
}
|
|
27348
28301
|
}
|
|
27349
28302
|
}
|
|
@@ -27359,13 +28312,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27359
28312
|
counts.shapeTested.add(im.impl.id);
|
|
27360
28313
|
}
|
|
27361
28314
|
const ov = im.poses.get(ps.id);
|
|
27362
|
-
const r =
|
|
28315
|
+
const r = rayPartInto(im.position, im.rotation, ps, ov?.q ?? specTurnOf(ps), origin, d, ov?.pos ?? ps.position);
|
|
27363
28316
|
if (!r || r.t1 < 0 || r.t0 > maxDist) continue;
|
|
27364
28317
|
if (r.t0 < 0) {
|
|
27365
|
-
if (precise && im.impl.surfaceRay) boxHit = boxHit ?? { object: im.impl.id, part: ps.id, point: origin, normal: r.n, distance: 0, pathLen: r.t1 };
|
|
28318
|
+
if (precise && im.impl.surfaceRay) boxHit = boxHit ?? { object: im.impl.id, part: ps.id, point: origin, normal: copyOf2(r.n), distance: 0, pathLen: r.t1 };
|
|
27366
28319
|
continue;
|
|
27367
28320
|
}
|
|
27368
|
-
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 };
|
|
28321
|
+
if (!boxHit || r.t0 < boxHit.distance) boxHit = { object: im.impl.id, part: ps.id, point: vec.madd(origin, d, r.t0), normal: copyOf2(r.n), distance: r.t0, pathLen: r.t1 - r.t0 };
|
|
27369
28322
|
}
|
|
27370
28323
|
if (!boxHit) continue;
|
|
27371
28324
|
if (precise && im.impl.surfaceRay) {
|
|
@@ -27713,6 +28666,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27713
28666
|
};
|
|
27714
28667
|
const isTrim = (p) => (p.spec.structure?.role ?? "none") === "none";
|
|
27715
28668
|
const fixesTrim = (o, j) => isTrim(o.parts[j.ia]) !== isTrim(o.parts[j.ib]);
|
|
28669
|
+
const bondedPlate = (o, p) => isPlateTrim(p) && (o.byPart.get(p.spec.id) ?? []).some((j) => !j.st.open && bondsPlate(o, j));
|
|
28670
|
+
const isPlateTrim = (p) => {
|
|
28671
|
+
if (!isTrim(p) || p.spec.units || p.spec.reinforcement || p.mat.ductility >= 0.5 || p.mat.fracture === "none" || p.mat.tags?.includes("glass") === true || p.spec.shape.kind !== "box") return false;
|
|
28672
|
+
const [u, v] = planeAxes(p.thin);
|
|
28673
|
+
return p.dims[p.thin] <= PLATE_ASPECT * Math.min(p.dims[u], p.dims[v]) && gridOf(p).length >= 2;
|
|
28674
|
+
};
|
|
28675
|
+
const bondsPlate = (o, j) => {
|
|
28676
|
+
if (!BONDING_JOINTS.has(j.spec.kind)) return false;
|
|
28677
|
+
const a = o.parts[j.ia], b = o.parts[j.ib];
|
|
28678
|
+
return isPlateTrim(a) && !isTrim(b) && backOn(a, b) || isPlateTrim(b) && !isTrim(a) && backOn(b, a);
|
|
28679
|
+
};
|
|
28680
|
+
const backOn = (plate2, carrier) => {
|
|
28681
|
+
const A = aabbOf(plate2.spec.shape, plate2.spec.position, plate2.q);
|
|
28682
|
+
const B = aabbOf(carrier.spec.shape, carrier.spec.position, carrier.q);
|
|
28683
|
+
const face = (k) => (Math.min(A.max[k], B.max[k]) - Math.max(A.min[k], B.min[k])) / Math.max(A.max[k] - A.min[k], 1e-9);
|
|
28684
|
+
const sides = [0, 1, 2].sort((x, y) => A.max[y] - A.min[y] - (A.max[x] - A.min[x])).slice(0, 2);
|
|
28685
|
+
return sides.every((k) => face(k) >= PLATE_BACK_SHARE);
|
|
28686
|
+
};
|
|
28687
|
+
const bondedShareLeft = (p) => {
|
|
28688
|
+
const whole2 = p.st.mass + (p.rt.removed ?? 0);
|
|
28689
|
+
return whole2 > 0 ? p.st.mass / whole2 : 0;
|
|
28690
|
+
};
|
|
28691
|
+
const settleBonded = (o, p, origin, dir, src) => {
|
|
28692
|
+
if (isLost(p)) return;
|
|
28693
|
+
const share = bondedShareLeft(p);
|
|
28694
|
+
p.st.hp = Math.max(1, Math.min(p.st.hp, p.st.maxHp * share));
|
|
28695
|
+
if (share < BONDED_REMNANT) failPart(o, p, origin, dir, 0, 4, src);
|
|
28696
|
+
};
|
|
27716
28697
|
const holdsEmbedded = (o, j) => {
|
|
27717
28698
|
const a = o.parts[j.ia], b = o.parts[j.ib];
|
|
27718
28699
|
return a.embedded === true && a.spec.hostedIn === b.spec.id && a.st.exposed !== true || b.embedded === true && b.spec.hostedIn === a.spec.id && b.st.exposed !== true;
|
|
@@ -27730,6 +28711,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27730
28711
|
if (j.st.open) continue;
|
|
27731
28712
|
if (j.spec.kind === "rebar" && (isReinforced(o.parts[j.ia].spec) || isReinforced(o.parts[j.ib].spec))) continue;
|
|
27732
28713
|
if (holdsEmbedded(o, j)) continue;
|
|
28714
|
+
if (bondsPlate(o, j)) continue;
|
|
27733
28715
|
if (near && jointReach(o, j, near) > Math.max(radius, jointReachLimit(o, j))) continue;
|
|
27734
28716
|
if (blast && fixesTrim(o, j) && jointReach(o, j, blast.point) > Math.max(blast.reach, jointReachLimit(o, j))) continue;
|
|
27735
28717
|
j.st.hp -= span === void 0 ? amount : Math.min(amount, j.st.maxHp) * Math.min(1, span / Math.max(jointLength(o, j), 1e-6));
|
|
@@ -27769,19 +28751,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27769
28751
|
emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: torn.layer.index, point: centre, area: Math.PI * r * r, ...spallNormal(o, p, s[1]) });
|
|
27770
28752
|
debris2(o, p, torn.layer.mat.hitDebris, toWorld(o.st.position, o.st.rotation, lp), normal, 5, 2, src, torn.layer.mat.id);
|
|
27771
28753
|
};
|
|
27772
|
-
const spallOuter = (o, p, wp, face, normal, radius, src) => {
|
|
28754
|
+
const spallOuter = (o, p, wp, face, normal, radius, src, tearRadius = radius) => {
|
|
27773
28755
|
var _a;
|
|
27774
28756
|
if (p.layers.length === 0) return;
|
|
27775
28757
|
const lp = objLocal(o, wp);
|
|
27776
28758
|
const torn = tornPatchAt(p.layers, p.rt.spalls, face, lp, radius);
|
|
27777
|
-
if (torn) return widenTear(o, p, torn, lp, normal,
|
|
28759
|
+
if (torn) return widenTear(o, p, torn, lp, normal, tearRadius, src);
|
|
27778
28760
|
const layer3 = outerLayer(p.layers, p.rt.spalls, face, lp);
|
|
27779
28761
|
if (!layer3) return;
|
|
28762
|
+
const patch = layer3.mat.fracture === "tear" ? tearRadius : radius;
|
|
27780
28763
|
const spalls = (_a = p.rt).spalls ?? (_a.spalls = []);
|
|
27781
|
-
spalls.push([layer3.index, face, lp[0], lp[1], lp[2],
|
|
28764
|
+
spalls.push([layer3.index, face, lp[0], lp[1], lp[2], patch]);
|
|
27782
28765
|
if (spalls.length > MAX_SPALLS) spalls.shift();
|
|
27783
28766
|
markDamaged(p);
|
|
27784
|
-
emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer3.index, point: wp, area: Math.PI *
|
|
28767
|
+
emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer3.index, point: wp, area: Math.PI * patch * patch, ...spallNormal(o, p, face) });
|
|
27785
28768
|
debris2(o, p, layer3.mat.hitDebris, wp, normal, 5, 2, src, layer3.mat.id);
|
|
27786
28769
|
setStage(o, p, 1, {}, src);
|
|
27787
28770
|
};
|
|
@@ -27821,7 +28804,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27821
28804
|
return first && first.size[u] > size[0] + 1e-6 ? [first.size[u], first.size[v]] : [Math.min(size[0], p.dims[u]), Math.min(size[1], p.dims[v])];
|
|
27822
28805
|
};
|
|
27823
28806
|
const FRAGMENT_SHAPE = { shatter: "shard", splinter: "splinter", tear: "scrap" };
|
|
27824
|
-
const
|
|
28807
|
+
const shardsOfCell = (cell, u, v) => {
|
|
28808
|
+
const own = createRng2(seedOf2(cell.center[0], cell.center[1], cell.center[2]));
|
|
28809
|
+
const cu = SHARD_CUT[0] + (SHARD_CUT[1] - SHARD_CUT[0]) * own.next(), cv = SHARD_CUT[0] + (SHARD_CUT[1] - SHARD_CUT[0]) * own.next();
|
|
28810
|
+
const out = [];
|
|
28811
|
+
for (const [a0, a1] of [[0, cu], [cu, 1]]) for (const [b0, b1] of [[0, cv], [cv, 1]]) {
|
|
28812
|
+
const size = [cell.size[0], cell.size[1], cell.size[2]];
|
|
28813
|
+
const center = [cell.center[0], cell.center[1], cell.center[2]];
|
|
28814
|
+
size[u] = cell.size[u] * (a1 - a0);
|
|
28815
|
+
size[v] = cell.size[v] * (b1 - b0);
|
|
28816
|
+
center[u] = cell.center[u] - cell.size[u] / 2 + cell.size[u] * (a0 + a1) / 2;
|
|
28817
|
+
center[v] = cell.center[v] - cell.size[v] / 2 + cell.size[v] * (b0 + b1) / 2;
|
|
28818
|
+
out.push({ ...cell, center, size });
|
|
28819
|
+
}
|
|
28820
|
+
return out;
|
|
28821
|
+
};
|
|
28822
|
+
const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false, knownHoles, drive = CHIP_DRIVE) => {
|
|
27825
28823
|
const { c, q } = partXf(o, p);
|
|
27826
28824
|
const holes = knownHoles ?? (p.st.holes.length > 0 ? localHolesOf(p) : []);
|
|
27827
28825
|
const [u, v] = planeAxes(p.thin);
|
|
@@ -27829,19 +28827,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27829
28827
|
const total = cells.reduce((sum2, cell) => sum2 + faceArea(cell), 0) || 1;
|
|
27830
28828
|
const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
|
|
27831
28829
|
const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
|
|
27832
|
-
|
|
28830
|
+
const pieces = shape === "shard" && bondedPlate(o, p) ? cells.flatMap((cell) => shardsOfCell(cell, u, v)) : cells;
|
|
28831
|
+
return pieces.map((cell, i) => {
|
|
27833
28832
|
const cw = toWorld(c, q, cell.center);
|
|
27834
28833
|
const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
|
|
27835
|
-
const dv = dir ? vec.normalize(vec.madd(out, dir,
|
|
28834
|
+
const dv = dir ? vec.normalize(vec.madd(out, dir, drive)) : out;
|
|
27836
28835
|
const k = speed * (0.6 + 0.8 * rnd2());
|
|
27837
28836
|
const marks = marksInBox(cell.center, cell.size, void 0, holes);
|
|
28837
|
+
const size = [cell.size[0], cell.size[1], cell.size[2]];
|
|
28838
|
+
if (laid) for (const a of [u, v]) size[a] = Math.max(size[a] * MIN_UNIT_SHARE, size[a] - MORTAR_JOINT);
|
|
27838
28839
|
return {
|
|
27839
28840
|
id: `${p.spec.id}#${tag}${i}`,
|
|
27840
28841
|
part: p.spec.id,
|
|
27841
28842
|
material: p.spec.material,
|
|
27842
28843
|
shape,
|
|
27843
28844
|
center: cw,
|
|
27844
|
-
size
|
|
28845
|
+
size,
|
|
27845
28846
|
rotation: q,
|
|
27846
28847
|
velocity: [dv[0] * k, dv[1] * k + 0.5 * rnd2(), dv[2] * k],
|
|
27847
28848
|
angularVelocity: bornSpin(cell.size, 8, rnd2),
|
|
@@ -28000,11 +29001,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28000
29001
|
const toPart = quat.conjugate(p.q);
|
|
28001
29002
|
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
28002
29003
|
const ld = rotateVec(toPart, objLocalDir(o, d));
|
|
28003
|
-
const
|
|
29004
|
+
const EPS33 = 1e-4;
|
|
28004
29005
|
let t = t0;
|
|
28005
29006
|
let axis2 = -1;
|
|
28006
29007
|
for (let step = 0; step < cells.length + 1; step++) {
|
|
28007
|
-
const at4 = vec.madd(lo, ld, t +
|
|
29008
|
+
const at4 = vec.madd(lo, ld, t + EPS33);
|
|
28008
29009
|
const cell = cells.find((c) => Math.abs(at4[0] - c.center[0]) <= c.size[0] / 2 && Math.abs(at4[1] - c.center[1]) <= c.size[1] / 2 && Math.abs(at4[2] - c.center[2]) <= c.size[2] / 2);
|
|
28009
29010
|
if (!cell) break;
|
|
28010
29011
|
let out = Infinity;
|
|
@@ -28017,25 +29018,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28017
29018
|
axis2 = a;
|
|
28018
29019
|
}
|
|
28019
29020
|
}
|
|
28020
|
-
if (!Number.isFinite(out) || out >= t1 -
|
|
28021
|
-
t = out + 2 *
|
|
29021
|
+
if (!Number.isFinite(out) || out >= t1 - EPS33) return "through";
|
|
29022
|
+
t = out + 2 * EPS33;
|
|
28022
29023
|
}
|
|
28023
29024
|
if (axis2 < 0) return null;
|
|
28024
29025
|
const local2 = [0, 0, 0];
|
|
28025
29026
|
local2[axis2] = -Math.sign(ld[axis2]);
|
|
28026
29027
|
return { t, n: rotateVec(o.st.rotation, rotateVec(p.q, local2)) };
|
|
28027
29028
|
};
|
|
29029
|
+
const coreBehind = (o, p, origin, d, t0, t1) => {
|
|
29030
|
+
const gap = pastChips(o, p, origin, d, t0, t1);
|
|
29031
|
+
const core = Math.min(t1, t0 + REBAR_COVER);
|
|
29032
|
+
if (gap === null || gap !== "through" && gap.t <= core) return gap;
|
|
29033
|
+
return { t: core, n: vec.scale(d, -1) };
|
|
29034
|
+
};
|
|
29035
|
+
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);
|
|
29036
|
+
const coreStands = (p, lp) => {
|
|
29037
|
+
if (!p.spec.reinforcement || !isMember(p.dims, p.spec.structure?.role) || p.st.stripped) return false;
|
|
29038
|
+
const along2 = p.dims.indexOf(Math.max(...p.dims));
|
|
29039
|
+
const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
|
|
29040
|
+
const band = clamp2(Math.floor((lp[along2] + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
|
|
29041
|
+
return (p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS;
|
|
29042
|
+
};
|
|
28028
29043
|
const insideChip = (p, objectPoint) => {
|
|
28029
29044
|
const cells = p.st.chipped;
|
|
28030
29045
|
if (!cells?.length) return false;
|
|
28031
29046
|
const [u, v] = planeAxes(p.thin);
|
|
28032
29047
|
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
28033
|
-
if (
|
|
28034
|
-
const along2 = p.dims.indexOf(Math.max(...p.dims));
|
|
28035
|
-
const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
|
|
28036
|
-
const band = clamp2(Math.floor((lp[along2] + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
|
|
28037
|
-
if ((p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS) return false;
|
|
28038
|
-
}
|
|
29048
|
+
if (coreStands(p, lp)) return false;
|
|
28039
29049
|
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);
|
|
28040
29050
|
};
|
|
28041
29051
|
const alongAt = (along2, at4) => {
|
|
@@ -28092,7 +29102,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28092
29102
|
};
|
|
28093
29103
|
const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
|
|
28094
29104
|
var _a, _b, _c;
|
|
28095
|
-
|
|
29105
|
+
const bonded = bondedPlate(o, p);
|
|
29106
|
+
if (!bonded && (!p.spec.units || !p.staged) || chipEnergy <= 0 || p.st.stripped || isLost(p) || (p.st.stage ?? 0) >= 2) return;
|
|
28096
29107
|
const rule = p.mat.hits?.[kind];
|
|
28097
29108
|
const perKg = rule?.unitJoules ?? chipEnergy;
|
|
28098
29109
|
const energy = hitEnergy - (rule?.floor ?? 0);
|
|
@@ -28166,6 +29177,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28166
29177
|
if (Object.values(worn).filter((w) => w === -1).length > wholeBefore) dropUnsupported(o, p, src);
|
|
28167
29178
|
if (p.spec.reinforcement) exposeRebar(o, p, src);
|
|
28168
29179
|
for (const cell of out) addBreach(o, p, toWorld(c, q, cell.center), cell.size[u] * cell.size[v], energy, dir, src);
|
|
29180
|
+
if (bonded) settleBonded(o, p, wp, dir, src);
|
|
28169
29181
|
if (p.structural && !isLost(p)) {
|
|
28170
29182
|
solveStructure(o);
|
|
28171
29183
|
collapseCheck(o, src);
|
|
@@ -28281,18 +29293,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28281
29293
|
if (p.structural) solveStructure(o);
|
|
28282
29294
|
};
|
|
28283
29295
|
const blastReachOf = (p, energy) => {
|
|
28284
|
-
const
|
|
28285
|
-
const resistance = Math.max(1, perKg * p.mat.density * p.thickness);
|
|
29296
|
+
const resistance = Math.max(1, (p.mat.hits?.blunt?.unitJoules ?? chipEnergy) * p.mat.density * p.thickness);
|
|
28286
29297
|
return BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3) * clamp2(Math.cbrt(BLAST_REFERENCE_RESISTANCE / resistance), 0.3, 2);
|
|
28287
29298
|
};
|
|
28288
|
-
const blastUnits = (o, p, wp, energy, dist2, src) => {
|
|
29299
|
+
const blastUnits = (o, p, wp, energy, dist2, src, from) => {
|
|
28289
29300
|
var _a;
|
|
28290
|
-
if (!p.staged || p.st.stripped || isLost(p) || chipEnergy <= 0) return false;
|
|
29301
|
+
if (!p.staged && !bondedPlate(o, p) || p.st.stripped || isLost(p) || chipEnergy <= 0) return false;
|
|
28291
29302
|
const reach2 = blastReachOf(p, energy);
|
|
28292
29303
|
if (dist2 >= reach2) return false;
|
|
28293
|
-
const radius = Math.sqrt(reach2 * reach2 - dist2 * dist2);
|
|
28294
29304
|
const [u, v] = planeAxes(p.thin);
|
|
28295
|
-
const
|
|
29305
|
+
const charge2 = from ? toLocal(p.pos, p.q, objLocal(o, from)) : null;
|
|
29306
|
+
const lp = charge2 ?? toLocal(p.pos, p.q, objLocal(o, wp));
|
|
29307
|
+
const off = charge2 ? Math.max(0, Math.abs(charge2[p.thin]) - p.dims[p.thin] / 2) : dist2;
|
|
29308
|
+
const radius = Math.sqrt(Math.max(0, reach2 * reach2 - off * off));
|
|
28296
29309
|
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
28297
29310
|
const grid = gridOf(p);
|
|
28298
29311
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
@@ -28316,7 +29329,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28316
29329
|
}
|
|
28317
29330
|
}
|
|
28318
29331
|
if (out.length === 0) return false;
|
|
28319
|
-
return knockOutUnits(o, p, wp, energy, out, src);
|
|
29332
|
+
return knockOutUnits(o, p, wp, energy, out, src, from ? awayFromCharge(o, p, from) : void 0, BLAST_DRIVE);
|
|
29333
|
+
};
|
|
29334
|
+
const awayFromCharge = (o, p, charge2) => {
|
|
29335
|
+
const axis2 = [0, 0, 0];
|
|
29336
|
+
axis2[p.thin] = toLocal(p.pos, p.q, objLocal(o, charge2))[p.thin] >= 0 ? -1 : 1;
|
|
29337
|
+
return rotateVec(partXf(o, p).q, axis2);
|
|
28320
29338
|
};
|
|
28321
29339
|
const wedgedUnder = (o, p, loose) => {
|
|
28322
29340
|
if (loose.length === 0) return loose;
|
|
@@ -28408,7 +29426,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28408
29426
|
for (const i of out) worn[i] = -1;
|
|
28409
29427
|
return knockOutUnits(o, p, point, energy, out, src);
|
|
28410
29428
|
};
|
|
28411
|
-
const knockOutUnits = (o, p, wp, energy, out, src, d) => {
|
|
29429
|
+
const knockOutUnits = (o, p, wp, energy, out, src, d, drive = CHIP_DRIVE) => {
|
|
28412
29430
|
var _a, _b;
|
|
28413
29431
|
const [u, v] = planeAxes(p.thin);
|
|
28414
29432
|
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
@@ -28418,7 +29436,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28418
29436
|
out = out.filter((i) => !castHere.has(i));
|
|
28419
29437
|
if (out.length === 0) return false;
|
|
28420
29438
|
for (const i of out) worn[i] = -1;
|
|
28421
|
-
const
|
|
29439
|
+
const bonded = bondedPlate(o, p);
|
|
29440
|
+
const cast = p.spec.units?.mortar === p.spec.material || bonded;
|
|
28422
29441
|
const loose = cast ? [] : wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !(op && p.st.opening && Math.hypot(grid[i].center[u] - op[u], grid[i].center[v] - op[v]) <= p.st.opening.radius))).filter((i) => !castHere.has(i));
|
|
28423
29442
|
for (const i of loose) worn[i] = -1;
|
|
28424
29443
|
const blown = out.map((i) => grid[i]), fallen = loose.map((i) => grid[i]);
|
|
@@ -28431,7 +29450,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28431
29450
|
const tag = `x${chipped.length}_`;
|
|
28432
29451
|
const holes = localHolesOf(p);
|
|
28433
29452
|
const fragments = [
|
|
28434
|
-
...cellFragments(o, p, clumpUnits(blown, p.thin, unitSpan(p), unitClumps), wp, null, speed, blownMass, tag, true, holes),
|
|
29453
|
+
...cellFragments(o, p, clumpUnits(blown, p.thin, unitSpan(p), unitClumps), wp, d ?? null, speed, blownMass, tag, true, holes, drive),
|
|
28435
29454
|
...fallen.length > 0 ? cellFragments(o, p, clumpUnits(fallen, p.thin, unitSpan(p), fallenClumps), wp, null, 0.3, fallenMass, `${tag}f`, true, holes) : [],
|
|
28436
29455
|
...plasterFlakes(o, p, blown, wp, speed, `${tag}p`)
|
|
28437
29456
|
];
|
|
@@ -28456,6 +29475,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28456
29475
|
debris2(o, p, p.mat.breakDebris, center, vec.normalize(vec.sub(center, wp), [0, 1, 0]), 14, 3, src);
|
|
28457
29476
|
const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
|
|
28458
29477
|
if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
|
|
29478
|
+
if (bonded) settleBonded(o, p, wp, d ?? null, src);
|
|
28459
29479
|
if (p.structural && !isLost(p)) {
|
|
28460
29480
|
solveStructure(o);
|
|
28461
29481
|
collapseCheck(o, src);
|
|
@@ -28567,6 +29587,55 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28567
29587
|
emit2({ ...base2(o, src), type: "yield", part: p.spec.id, joint: h.joint, point, toward: rotateVec(o.st.rotation, h.toward), moment: h.moment });
|
|
28568
29588
|
}
|
|
28569
29589
|
};
|
|
29590
|
+
const barAlong = (o, p, origin, d, t0, t1) => {
|
|
29591
|
+
const r = p.spec.reinforcement;
|
|
29592
|
+
if (!r || !isMember(p.dims, p.spec.structure?.role)) return null;
|
|
29593
|
+
const along2 = p.dims.indexOf(Math.max(...p.dims));
|
|
29594
|
+
const [u, v] = [0, 1, 2].filter((k) => k !== along2);
|
|
29595
|
+
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
29596
|
+
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
29597
|
+
const across2 = Math.hypot(ld[u], ld[v]);
|
|
29598
|
+
if (across2 < 1e-6) return null;
|
|
29599
|
+
const cut = p.rt.severedBars ?? [];
|
|
29600
|
+
let best = null;
|
|
29601
|
+
rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a], i) => {
|
|
29602
|
+
if (cut.includes(i)) return;
|
|
29603
|
+
const du = a[u] - lo[u];
|
|
29604
|
+
const dv = a[v] - lo[v];
|
|
29605
|
+
if (Math.abs(du * ld[v] - dv * ld[u]) / across2 > r.diameter / 2) return;
|
|
29606
|
+
const t = (du * ld[u] + dv * ld[v]) / (across2 * across2);
|
|
29607
|
+
if (t >= t0 && t <= t1 && (best === null || t < best)) best = t;
|
|
29608
|
+
});
|
|
29609
|
+
return best;
|
|
29610
|
+
};
|
|
29611
|
+
const cutCageBars = (o, p, origin, d, caliber, src) => {
|
|
29612
|
+
var _a;
|
|
29613
|
+
const r = p.spec.reinforcement;
|
|
29614
|
+
if (!r || isLost(p)) return;
|
|
29615
|
+
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
29616
|
+
const ld = vec.normalize(rotateVec(quat.conjugate(p.q), objLocalDir(o, d)));
|
|
29617
|
+
const reach2 = r.diameter / 2 + caliber / 2e3;
|
|
29618
|
+
const cut = (_a = p.rt).severedBars ?? (_a.severedBars = []);
|
|
29619
|
+
let severed = 0;
|
|
29620
|
+
rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a, b], i) => {
|
|
29621
|
+
if (cut.includes(i)) return;
|
|
29622
|
+
const near = lineToSegment(lo, ld, a, b);
|
|
29623
|
+
if (!near || near.distance > reach2) return;
|
|
29624
|
+
cut.push(i);
|
|
29625
|
+
severed++;
|
|
29626
|
+
debris2(o, p, "sparks", toWorld(o.st.position, o.st.rotation, toWorld(p.pos, p.q, near.point)), vec.scale(d, -1), 6, 3, src);
|
|
29627
|
+
});
|
|
29628
|
+
if (severed === 0) return;
|
|
29629
|
+
markDamaged(p);
|
|
29630
|
+
if (cageLeft(p) <= 0) {
|
|
29631
|
+
if (p.rt.hinges?.length) reyield(o, p, 0, src);
|
|
29632
|
+
loseCage(o, p, src);
|
|
29633
|
+
return;
|
|
29634
|
+
}
|
|
29635
|
+
if (p.rt.hinges?.length) reyield(o, p, barsMoment(p), src);
|
|
29636
|
+
solveStructure(o);
|
|
29637
|
+
collapseCheck(o, src);
|
|
29638
|
+
};
|
|
28570
29639
|
const severBars = (o, p, origin, d, caliber, src) => {
|
|
28571
29640
|
var _a;
|
|
28572
29641
|
const r = p.spec.reinforcement;
|
|
@@ -28666,7 +29735,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28666
29735
|
return;
|
|
28667
29736
|
}
|
|
28668
29737
|
if (p.bend) settleStructure(o);
|
|
28669
|
-
if (!force && p.bend && (p.st.flexure ?? 0) > 1 &&
|
|
29738
|
+
if (!force && p.bend && (p.st.flexure ?? 0) > 1 && sectionOf22(p, p.bend.gravity).reinforced) {
|
|
28670
29739
|
hingeDrop(o, p, src);
|
|
28671
29740
|
return;
|
|
28672
29741
|
}
|
|
@@ -28798,6 +29867,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28798
29867
|
if (chained && p.st.hp <= 0 && p.rt.chainDue === void 0) p.st.hp = Math.min(prev, 1);
|
|
28799
29868
|
if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
|
|
28800
29869
|
if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
|
|
29870
|
+
if (p.st.hp <= 0 && type !== "fire" && type !== "heat" && bondedPlate(o, p)) p.st.hp = Math.min(prev, 1);
|
|
28801
29871
|
const done = prev - p.st.hp;
|
|
28802
29872
|
if (done > 0) emit2({ ...base2(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
|
|
28803
29873
|
if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy * weight, cap, src);
|
|
@@ -28880,6 +29950,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28880
29950
|
const piece3 = round5.piece;
|
|
28881
29951
|
const weight = piece3?.weight ?? 1;
|
|
28882
29952
|
const piercing = round5.piercing ?? 1;
|
|
29953
|
+
if (p.st.stripped && p.spec.reinforcement) cutCageBars(o, p, entry2, d, caliber, src);
|
|
28883
29954
|
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))))) {
|
|
28884
29955
|
return { penetrated: true, exitEnergy: E, exitPoint: vec.madd(entry2, d, Math.min(pathLen, p.thickness)), damage: 0 };
|
|
28885
29956
|
}
|
|
@@ -28906,7 +29977,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28906
29977
|
const dmg2 = applyDamage(o, p, E * DMG_PER_J * scale * 0.2, "ballistic", entry2, d, E * 0.1, 12, src, weight);
|
|
28907
29978
|
return { penetrated: false, exitEnergy: 0, damage: dmg2 };
|
|
28908
29979
|
}
|
|
28909
|
-
if (p.layers.length > 0) spallOuter(o, p, entry2, face, n, Math.max(0.03, caliber / 1e3 * 4), src);
|
|
29980
|
+
if (p.layers.length > 0) spallOuter(o, p, entry2, face, n, Math.max(0.03, caliber / 1e3 * 4), src, caliber / 1e3 * TEAR_CALIBERS);
|
|
28910
29981
|
else if (mat.hits?.ballistic?.crater) crater(o, p, entry2, n, clamp2(0.02 + Math.sqrt(E) * 15e-4, 0.02, 0.15), src);
|
|
28911
29982
|
const brittle = mat.ductility < 0.3;
|
|
28912
29983
|
const ratio = Ep / Math.max(thr, 1e-6);
|
|
@@ -28919,7 +29990,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28919
29990
|
exitPoint = vec.madd(entry2, d, exitDist);
|
|
28920
29991
|
const hole = addHole(o, p, entry2, n, holeWidth, true, exitPoint, src);
|
|
28921
29992
|
shellShare = wearsShell(p, hole.diameter * 2);
|
|
28922
|
-
if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src);
|
|
29993
|
+
if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src, caliber / 1e3 * TEAR_CALIBERS);
|
|
28923
29994
|
addBreach(o, p, entry2, Math.PI * (hole.diameter / 2) * (hole.diameter / 2), E, d, src);
|
|
28924
29995
|
if (mat.ductility >= 0.5 && p.thickness <= THIN_SHEET_DISHING) addDent(o, p, entry2, n, Math.max(caliber * 3 / 1e3, 0.012), clamp2(E * 2e-5, 1e-3, 0.03), src);
|
|
28925
29996
|
if (brittle && mat.fracture === "shatter") addCrack(o, p, entry2, n, crackLen, src);
|
|
@@ -29091,13 +30162,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29091
30162
|
const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
|
|
29092
30163
|
const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
|
|
29093
30164
|
const member = caged2 && (isMember(p.dims, p.spec.structure?.role) || dist2 > MEMBER_CUT_REACH * breachReach);
|
|
29094
|
-
const
|
|
30165
|
+
const bonded = bondedPlate(o, p);
|
|
30166
|
+
const dealt = bonded ? applyDamage(o, p, Math.min(amount, Math.max(0, p.st.hp - 1)), "explosive", null, null, Ein * 0.3, 40, src) : member ? applyDamage(o, p, Math.min(amount, Math.max(0, p.st.hp - p.st.maxHp * FAR_MEMBER_HP_FLOOR)), "explosive", null, null, Ein * 0.3, 40, src) : applyDamage(o, p, amount, "explosive", point, null, Ein * 0.3, 40, src);
|
|
29095
30167
|
res.damage += dealt;
|
|
29096
30168
|
if (p.bend && flexure.enabled) bendByBlast(o, p, point, energy, radius, reach2, src);
|
|
29097
30169
|
if (p.spec.units && p.spec.units.mortar !== p.spec.material) {
|
|
29098
30170
|
blastPanel(o, p, point, energy, src);
|
|
29099
|
-
if (!isLost(p)) blastUnits(o, p, wp, energy, dist2, src);
|
|
29100
|
-
} else if (member) blastUnits(o, p, wp, energy, dist2, src);
|
|
30171
|
+
if (!isLost(p)) blastUnits(o, p, wp, energy, dist2, src, point);
|
|
30172
|
+
} else if (member || bonded) blastUnits(o, p, wp, energy, dist2, src, point);
|
|
29101
30173
|
else if (dist2 <= breachReach) addBreach(o, p, wp, breachAreaOf(p, dealt, true), Ein, null, src);
|
|
29102
30174
|
return reach2;
|
|
29103
30175
|
};
|
|
@@ -30635,6 +31707,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30635
31707
|
}).events;
|
|
30636
31708
|
},
|
|
30637
31709
|
state: (id) => objects.get(id)?.st ?? impls.get(id)?.impl.state() ?? null,
|
|
31710
|
+
layers: (id, partId) => objects.get(id)?.byId.get(partId)?.spec.layers ?? [],
|
|
30638
31711
|
anchoredParts: (id) => objects.get(id)?.parts.filter((p) => p.anchored && !isLost(p)).map((p) => p.spec.id) ?? [],
|
|
30639
31712
|
fixedInPlace: (id) => {
|
|
30640
31713
|
const o = objects.get(id);
|
|
@@ -30645,6 +31718,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30645
31718
|
return st ? clone(st) : null;
|
|
30646
31719
|
},
|
|
30647
31720
|
part: (id, partId) => objects.get(id)?.byId.get(partId)?.st ?? impls.get(id)?.impl.state().parts.find((p) => p.id === partId) ?? null,
|
|
31721
|
+
assemblyFlex(id, options2) {
|
|
31722
|
+
const o = objects.get(id);
|
|
31723
|
+
if (!o) return null;
|
|
31724
|
+
const lost = new Set(options2?.lost ?? []);
|
|
31725
|
+
const kept = new Set(o.st.groups[0] ?? []);
|
|
31726
|
+
const framed = o.parts.filter((p) => lost.has(p.spec.id) || kept.has(p.spec.id) && !isLost(p));
|
|
31727
|
+
const ids = new Set(framed.map((p) => p.spec.id));
|
|
31728
|
+
const parts2 = framed.map((p) => ({
|
|
31729
|
+
id: p.spec.id,
|
|
31730
|
+
material: p.mat,
|
|
31731
|
+
dims: p.dims,
|
|
31732
|
+
position: p.pos,
|
|
31733
|
+
rotation: p.q,
|
|
31734
|
+
// a part that went is taken whole, as it was while it held
|
|
31735
|
+
mass: lost.has(p.spec.id) ? p.mass0 : p.st.mass,
|
|
31736
|
+
...p.spec.grain ? { grain: GRAIN_AXIS[p.spec.grain] } : {},
|
|
31737
|
+
...p.spec.shape.kind === "cylinder" ? { round: true } : {}
|
|
31738
|
+
}));
|
|
31739
|
+
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 }));
|
|
31740
|
+
return assemblyFlex({ parts: parts2, joints, lost: [...lost], ...options2?.loads ? { loads: options2.loads } : {}, ...options2?.friction !== void 0 ? { friction: options2.friction } : {} });
|
|
31741
|
+
},
|
|
30648
31742
|
reset(id) {
|
|
30649
31743
|
finishExplosions();
|
|
30650
31744
|
const im = impls.get(id);
|
|
@@ -31186,7 +32280,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31186
32280
|
var MIN_PILLAR_AREA = 0.036;
|
|
31187
32281
|
var BEAM_DEPTH_RATIO = 10;
|
|
31188
32282
|
var PLASTER_PER_FACE = 0.015;
|
|
31189
|
-
var
|
|
32283
|
+
var MORTAR_JOINT2 = 0.01;
|
|
31190
32284
|
var SECTION_STEP = 0.05;
|
|
31191
32285
|
var ceilTo = (value, step) => Math.ceil(value / step - 1e-9) * step;
|
|
31192
32286
|
var round22 = (value) => Math.round(value * 100) / 100;
|
|
@@ -31200,7 +32294,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31200
32294
|
function coursingOf(unitId, assemblyUnits) {
|
|
31201
32295
|
if (unitId !== void 0) {
|
|
31202
32296
|
const unit = getMasonryUnit(unitId);
|
|
31203
|
-
return { courseHeight: round22(unit.height +
|
|
32297
|
+
return { courseHeight: round22(unit.height + MORTAR_JOINT2), unitLength: round22(unit.length + MORTAR_JOINT2) };
|
|
31204
32298
|
}
|
|
31205
32299
|
return assemblyUnits ? { courseHeight: assemblyUnits.size[1], unitLength: assemblyUnits.size[0] } : void 0;
|
|
31206
32300
|
}
|
|
@@ -31640,7 +32734,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31640
32734
|
var BELOW = 0.35;
|
|
31641
32735
|
var UP = 0.15;
|
|
31642
32736
|
var END_REACH = 0.35;
|
|
31643
|
-
var
|
|
32737
|
+
var EPS23 = 1e-6;
|
|
31644
32738
|
var HOUSE_SHARING = "all";
|
|
31645
32739
|
var BEARING = 0.15;
|
|
31646
32740
|
var JAMB_CLEAR = 0.02;
|
|
@@ -31651,7 +32745,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31651
32745
|
const out = [];
|
|
31652
32746
|
for (const [a, b] of intervals.slice().sort((x, y) => x[0] - y[0])) {
|
|
31653
32747
|
const last = out[out.length - 1];
|
|
31654
|
-
if (last && a <= last[1] +
|
|
32748
|
+
if (last && a <= last[1] + EPS23) last[1] = Math.max(last[1], b);
|
|
31655
32749
|
else out.push([a, b]);
|
|
31656
32750
|
}
|
|
31657
32751
|
return out;
|
|
@@ -31822,7 +32916,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31822
32916
|
}
|
|
31823
32917
|
return { u, v, alongU };
|
|
31824
32918
|
}
|
|
31825
|
-
function
|
|
32919
|
+
function sectionOf3(structure, options) {
|
|
31826
32920
|
const unit = structure.construction.walls.unit;
|
|
31827
32921
|
return typeof unit === "string" ? pillarSectionOf(getMasonryUnit(unit)) : { across: options.columnSide, along: options.columnSide };
|
|
31828
32922
|
}
|
|
@@ -31976,13 +33070,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31976
33070
|
for (const { beam, host } of framings) rest(context, host, beam);
|
|
31977
33071
|
for (const { part: beam } of beams) {
|
|
31978
33072
|
const depth = depthToCarry(beam, context, options.beamStep);
|
|
31979
|
-
if (depth > beam.y1 - beam.y0 +
|
|
33073
|
+
if (depth > beam.y1 - beam.y0 + EPS23) deepen(beam, depth);
|
|
31980
33074
|
}
|
|
31981
33075
|
for (let changed = true, guard = 0; changed && guard < framings.length + 1; guard++) {
|
|
31982
33076
|
changed = false;
|
|
31983
33077
|
for (const { beam, host } of framings) {
|
|
31984
33078
|
const section = sectionDepthAt(host, beam.aabb, context.parts);
|
|
31985
|
-
if (section >= depthToHold(host, beam) -
|
|
33079
|
+
if (section >= depthToHold(host, beam) - EPS23 || section > host.y1 - host.y0 + EPS23) continue;
|
|
31986
33080
|
deepen(host, depthToHold(host, beam));
|
|
31987
33081
|
changed = true;
|
|
31988
33082
|
}
|
|
@@ -32041,7 +33135,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32041
33135
|
const [gu0, gv0] = pointOf(line, found.lo);
|
|
32042
33136
|
const [gu1, gv1] = pointOf(line, found.hi);
|
|
32043
33137
|
const gap = [Math.min(gu0, gu1) - width / 2, Math.min(gv0, gv1) - width / 2, Math.max(gu0, gu1) + width / 2, Math.max(gv0, gv1) + width / 2];
|
|
32044
|
-
if (span > 1.5 && Number.isFinite(span) && sectionDepthAt(plate2, gap, context.parts) < beamDepthFor(span, options) -
|
|
33138
|
+
if (span > 1.5 && Number.isFinite(span) && sectionDepthAt(plate2, gap, context.parts) < beamDepthFor(span, options) - EPS23) {
|
|
32045
33139
|
const depth = Math.max(plate2.y1 - plate2.y0, beamDepthFor(span, options));
|
|
32046
33140
|
plate2.y0 = round2(plate2.y1 - depth);
|
|
32047
33141
|
plate2.mass = Math.max(1, Math.round((plate2.aabb[2] - plate2.aabb[0]) * (plate2.aabb[3] - plate2.aabb[1]) * depth * densityOf(plate2.material)));
|
|
@@ -32072,7 +33166,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32072
33166
|
panelsOf: /* @__PURE__ */ new Map(),
|
|
32073
33167
|
pillars: 0,
|
|
32074
33168
|
groundBase: firstColumn?.on ?? GROUND,
|
|
32075
|
-
section:
|
|
33169
|
+
section: sectionOf3(structure, options)
|
|
32076
33170
|
};
|
|
32077
33171
|
const walls = parts2.filter((p) => /^wall_/.test(p.id) && (p.role === "wall" || p.role === "partition"));
|
|
32078
33172
|
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));
|
|
@@ -32089,7 +33183,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32089
33183
|
for (const beam of context.parts) {
|
|
32090
33184
|
if (beam.role !== "beam" || beam.slab === void 0 || !/_b\d+$/.test(beam.id)) continue;
|
|
32091
33185
|
const depth = depthToCarry(beam, context, options.beamStep);
|
|
32092
|
-
if (depth > beam.y1 - beam.y0 +
|
|
33186
|
+
if (depth > beam.y1 - beam.y0 + EPS23) deepen(beam, depth);
|
|
32093
33187
|
}
|
|
32094
33188
|
return { parts: context.parts, supports: context.supports };
|
|
32095
33189
|
}
|
|
@@ -44920,7 +46014,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
44920
46014
|
],
|
|
44921
46015
|
estimated: [
|
|
44922
46016
|
"parts"
|
|
44923
|
-
]
|
|
46017
|
+
],
|
|
46018
|
+
consumable: {
|
|
46019
|
+
form: "bar",
|
|
46020
|
+
unit: "g",
|
|
46021
|
+
amount: 100,
|
|
46022
|
+
dose: 1.5,
|
|
46023
|
+
emptyKg: 0
|
|
46024
|
+
}
|
|
44924
46025
|
},
|
|
44925
46026
|
{
|
|
44926
46027
|
id: "shampoo",
|
|
@@ -44938,7 +46039,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
44938
46039
|
stack: 3,
|
|
44939
46040
|
shape: "bottle",
|
|
44940
46041
|
color: 4885200,
|
|
44941
|
-
rarity: "common"
|
|
46042
|
+
rarity: "common",
|
|
46043
|
+
consumable: {
|
|
46044
|
+
form: "liquid",
|
|
46045
|
+
unit: "ml",
|
|
46046
|
+
amount: 300,
|
|
46047
|
+
dose: 8,
|
|
46048
|
+
emptyKg: 0.044,
|
|
46049
|
+
density: 1.02
|
|
46050
|
+
}
|
|
44942
46051
|
},
|
|
44943
46052
|
{
|
|
44944
46053
|
id: "toothpaste",
|
|
@@ -44956,7 +46065,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
44956
46065
|
stack: 3,
|
|
44957
46066
|
shape: "tube",
|
|
44958
46067
|
color: 15790320,
|
|
44959
|
-
rarity: "common"
|
|
46068
|
+
rarity: "common",
|
|
46069
|
+
consumable: {
|
|
46070
|
+
form: "paste",
|
|
46071
|
+
unit: "g",
|
|
46072
|
+
amount: 90,
|
|
46073
|
+
dose: 1,
|
|
46074
|
+
emptyKg: 0.01
|
|
46075
|
+
}
|
|
44960
46076
|
},
|
|
44961
46077
|
{
|
|
44962
46078
|
id: "toothbrush",
|
|
@@ -56480,7 +57596,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
56480
57596
|
}
|
|
56481
57597
|
var residentialTower = residentialTowerTemplate();
|
|
56482
57598
|
|
|
56483
|
-
// ../game-floorplan-three/dist/chunk-
|
|
57599
|
+
// ../game-floorplan-three/dist/chunk-RW7ZTU76.js
|
|
56484
57600
|
var __defProp4 = Object.defineProperty;
|
|
56485
57601
|
var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
56486
57602
|
var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -60945,21 +62061,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60945
62061
|
const defined = { drainPipes };
|
|
60946
62062
|
Object.assign(K, defined);
|
|
60947
62063
|
}
|
|
60948
|
-
var
|
|
62064
|
+
var EPS24 = 1e-4;
|
|
60949
62065
|
function subtractRects(base2, holes) {
|
|
60950
62066
|
let pieces = [base2];
|
|
60951
62067
|
for (const h of holes) {
|
|
60952
62068
|
const next = [];
|
|
60953
62069
|
for (const r of pieces) {
|
|
60954
62070
|
const a0 = Math.max(r.a0, h.a0), a1 = Math.min(r.a1, h.a1), y0 = Math.max(r.y0, h.y0), y1 = Math.min(r.y1, h.y1);
|
|
60955
|
-
if (a1 - a0 <
|
|
62071
|
+
if (a1 - a0 < EPS24 || y1 - y0 < EPS24) {
|
|
60956
62072
|
next.push(r);
|
|
60957
62073
|
continue;
|
|
60958
62074
|
}
|
|
60959
|
-
if (a0 - r.a0 >
|
|
60960
|
-
if (r.a1 - a1 >
|
|
60961
|
-
if (y0 - r.y0 >
|
|
60962
|
-
if (r.y1 - y1 >
|
|
62075
|
+
if (a0 - r.a0 > EPS24) next.push({ a0: r.a0, a1: a0, y0: r.y0, y1: r.y1 });
|
|
62076
|
+
if (r.a1 - a1 > EPS24) next.push({ a0: a1, a1: r.a1, y0: r.y0, y1: r.y1 });
|
|
62077
|
+
if (y0 - r.y0 > EPS24) next.push({ a0, a1, y0: r.y0, y1: y0 });
|
|
62078
|
+
if (r.y1 - y1 > EPS24) next.push({ a0, a1, y0: y1, y1: r.y1 });
|
|
60963
62079
|
}
|
|
60964
62080
|
pieces = next;
|
|
60965
62081
|
}
|
|
@@ -60975,7 +62091,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60975
62091
|
const across0 = wall.alongU ? v0 : u0, across1 = wall.alongU ? v1 : u1;
|
|
60976
62092
|
const half = wall.thickness / 2;
|
|
60977
62093
|
const covered = Math.min(across1, wall.line + half) - Math.max(across0, wall.line - half);
|
|
60978
|
-
if (covered < Math.min(wall.thickness * 0.3, across1 - across0) -
|
|
62094
|
+
if (covered < Math.min(wall.thickness * 0.3, across1 - across0) - EPS24) return null;
|
|
60979
62095
|
return wall.alongU ? { a0: u0, a1: u1, y0, y1 } : { a0: v0, a1: v1, y0, y1 };
|
|
60980
62096
|
}
|
|
60981
62097
|
function addStageBox(THREE, parent, x0, y0, z0, x1, y1, z1, mat, partId) {
|
|
@@ -66192,6 +67308,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66192
67308
|
}
|
|
66193
67309
|
return [...groups.values()];
|
|
66194
67310
|
};
|
|
67311
|
+
function subtract2(boxes, cuts) {
|
|
67312
|
+
let out = [...boxes];
|
|
67313
|
+
for (const k of cuts) {
|
|
67314
|
+
const next = [];
|
|
67315
|
+
for (const b of out) {
|
|
67316
|
+
if (k.a >= b.b - EPSILON22 || k.b <= b.a + EPSILON22 || k.y0 >= b.y1 - EPSILON22 || k.y1 <= b.y0 + EPSILON22) {
|
|
67317
|
+
next.push(b);
|
|
67318
|
+
continue;
|
|
67319
|
+
}
|
|
67320
|
+
const y0 = Math.max(b.y0, k.y0), y1 = Math.min(b.y1, k.y1);
|
|
67321
|
+
if (y0 - b.y0 > EPSILON22) next.push({ a: b.a, b: b.b, y0: b.y0, y1: y0 });
|
|
67322
|
+
if (b.y1 - y1 > EPSILON22) next.push({ a: b.a, b: b.b, y0: y1, y1: b.y1 });
|
|
67323
|
+
if (k.a - b.a > EPSILON22) next.push({ a: b.a, b: k.a, y0, y1 });
|
|
67324
|
+
if (b.b - k.b > EPSILON22) next.push({ a: k.b, b: b.b, y0, y1 });
|
|
67325
|
+
}
|
|
67326
|
+
out = next;
|
|
67327
|
+
}
|
|
67328
|
+
return out;
|
|
67329
|
+
}
|
|
66195
67330
|
function mergeSpans(spans, share = JOINT_SHARE) {
|
|
66196
67331
|
const runs = [];
|
|
66197
67332
|
const unitLengths = /* @__PURE__ */ new Map();
|
|
@@ -66242,7 +67377,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66242
67377
|
const point = new THREE.Vector3();
|
|
66243
67378
|
const out = [];
|
|
66244
67379
|
for (const part of parts2) {
|
|
66245
|
-
const boxes = mergeSpans(part.spans);
|
|
67380
|
+
const boxes = part.gone?.length ? subtract2(mergeSpans(part.spans), part.gone) : mergeSpans(part.spans);
|
|
66246
67381
|
for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
|
|
66247
67382
|
const along2 = line.start + (s.a + s.b) / 2;
|
|
66248
67383
|
point.set(line.alongU ? along2 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along2).applyMatrix4(toMesh);
|
|
@@ -66294,18 +67429,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66294
67429
|
if (list2) mesh3.userData.collapsedRanges = list2.filter((r) => r[0] !== v0);
|
|
66295
67430
|
withdrawSolids(mesh3, v0);
|
|
66296
67431
|
}
|
|
67432
|
+
var hash2 = (i, j) => {
|
|
67433
|
+
const s = Math.sin(i * 127.1 + j * 311.7) * 43758.5453;
|
|
67434
|
+
return s - Math.floor(s);
|
|
67435
|
+
};
|
|
66297
67436
|
function noise2(x, y, cell) {
|
|
66298
|
-
const h = (i2, j2) => {
|
|
66299
|
-
const s = Math.sin(i2 * 127.1 + j2 * 311.7) * 43758.5453;
|
|
66300
|
-
return s - Math.floor(s);
|
|
66301
|
-
};
|
|
66302
67437
|
const fx = x / cell, fy = y / cell, i = Math.floor(fx), j = Math.floor(fy), u = fx - i, v = fy - j;
|
|
66303
67438
|
const su = u * u * (3 - 2 * u), sv = v * v * (3 - 2 * v);
|
|
66304
|
-
return (
|
|
67439
|
+
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;
|
|
66305
67440
|
}
|
|
66306
67441
|
var MASK_TEXEL = 0.02;
|
|
66307
67442
|
var SPALL_MIN = 0.025;
|
|
66308
67443
|
var SPALL_RAGGED = 0.045;
|
|
67444
|
+
var PLASTER_REACH = { least: SPALL_MIN, band: SPALL_RAGGED };
|
|
66309
67445
|
var COVER2 = 0.015;
|
|
66310
67446
|
var LUMP_BAR_INSET = 0.035;
|
|
66311
67447
|
var LUMPS_PER_BAR = 1;
|
|
@@ -66748,11 +67884,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66748
67884
|
function publishStanding(view) {
|
|
66749
67885
|
if (!view.saved) return;
|
|
66750
67886
|
const { mask } = view;
|
|
67887
|
+
const along2 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
|
|
66751
67888
|
const parts2 = view.parts.map((id) => {
|
|
66752
67889
|
const part = structure.byId.get(id);
|
|
66753
67890
|
const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
|
|
66754
67891
|
const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
|
|
66755
|
-
|
|
67892
|
+
const gone = (view.chips.get(id) ?? []).map((k) => ({ a: along2(k.center) - k.along, b: along2(k.center) + k.along, y0: k.center[1] - k.up, y1: k.center[1] + k.up }));
|
|
67893
|
+
return { spans: view.kept.get(id) ?? [], gone, thick, mid };
|
|
66756
67894
|
});
|
|
66757
67895
|
const line = { alongU: mask.alongU, start: mask.start, open: view.core };
|
|
66758
67896
|
view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));
|
|
@@ -66799,7 +67937,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66799
67937
|
mask.data.fill(0);
|
|
66800
67938
|
core.data.fill(0);
|
|
66801
67939
|
const stamp = (m, s0, s1, y0, y1, inside22) => stampMask(m, { s0, s1, y0, y1, reach: reach2 }, inside22);
|
|
66802
|
-
const
|
|
67940
|
+
const texel = { s: 0, y: 0 };
|
|
67941
|
+
const raggedAtTexel = () => ragged(texel.s, texel.y);
|
|
67942
|
+
const coreNoiseAtTexel = () => noise2(texel.s * 1.7, texel.y * 1.3, 0.012);
|
|
67943
|
+
const plaster = (d, s, y) => {
|
|
67944
|
+
texel.s = s;
|
|
67945
|
+
texel.y = y;
|
|
67946
|
+
return isPlasterGone(d, PLASTER_REACH, raggedAtTexel);
|
|
67947
|
+
};
|
|
67948
|
+
const coreThrough = (distance4, depth, s, y) => {
|
|
67949
|
+
texel.s = s;
|
|
67950
|
+
texel.y = y;
|
|
67951
|
+
return isCoreThrough(distance4, depth, coreNoiseAtTexel);
|
|
67952
|
+
};
|
|
66803
67953
|
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));
|
|
66804
67954
|
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));
|
|
66805
67955
|
for (const f of flakes) {
|
|
@@ -66808,7 +67958,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66808
67958
|
}
|
|
66809
67959
|
for (const p of pits) {
|
|
66810
67960
|
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));
|
|
66811
|
-
stamp(core, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) =>
|
|
67961
|
+
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));
|
|
66812
67962
|
}
|
|
66813
67963
|
for (const q of pillars) {
|
|
66814
67964
|
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));
|
|
@@ -67552,7 +68702,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67552
68702
|
const left = breach.standing(part.id);
|
|
67553
68703
|
if (!left) return true;
|
|
67554
68704
|
const s0 = (left.alongU ? lx : lz) - left.start;
|
|
67555
|
-
|
|
68705
|
+
const low1 = Math.min(ly0, ly1), high1 = Math.max(ly0, ly1);
|
|
68706
|
+
for (const c of left.spans) if (c.b > s0 - radius && c.a < s0 + radius && c.y1 > low1 && c.y0 < high1) return true;
|
|
67556
68707
|
}
|
|
67557
68708
|
return false;
|
|
67558
68709
|
};
|
|
@@ -69178,7 +70329,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69178
70329
|
var HOLD_REACH2 = 0.05;
|
|
69179
70330
|
var BACK_TOUCH = 0.02;
|
|
69180
70331
|
var AGAINST_WALL = 0.1;
|
|
69181
|
-
var
|
|
70332
|
+
var SOFT2 = /* @__PURE__ */ new Set(["fabric", "paper", "foliage"]);
|
|
69182
70333
|
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])));
|
|
69183
70334
|
function groupsOf(parts2, joints) {
|
|
69184
70335
|
const root = new Map(parts2.map((part) => [part.id, part.id]));
|
|
@@ -69249,7 +70400,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69249
70400
|
continue;
|
|
69250
70401
|
}
|
|
69251
70402
|
const againstWall = held.length === 0 || held.some((part) => boxOf4(part.id).min[2] <= back2 + AGAINST_WALL);
|
|
69252
|
-
const onWall = againstWall ? group.filter((part) => !
|
|
70403
|
+
const onWall = againstWall ? group.filter((part) => !SOFT2.has(part.material) && boxOf4(part.id).min[2] <= back2 + BACK_TOUCH) : [];
|
|
69253
70404
|
if (onWall.length === 0) continue;
|
|
69254
70405
|
for (const part of onWall) part.anchored = true;
|
|
69255
70406
|
changed = true;
|
|
@@ -90592,7 +91743,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
90592
91743
|
var MAX_CASINGS = 120;
|
|
90593
91744
|
var MAX_MAGAZINES = 12;
|
|
90594
91745
|
var LIFETIME_S = 25;
|
|
90595
|
-
var
|
|
91746
|
+
var GRAVITY3 = 9.81;
|
|
90596
91747
|
function createBoxFx(options) {
|
|
90597
91748
|
const { THREE, scene, camera: camera2, arsenal, groundAt } = options;
|
|
90598
91749
|
const audio = options.audio ?? null;
|
|
@@ -90763,7 +91914,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
90763
91914
|
const stepBody = (body, dt) => {
|
|
90764
91915
|
body.age += dt;
|
|
90765
91916
|
if (body.resting) return;
|
|
90766
|
-
body.velocity.y -=
|
|
91917
|
+
body.velocity.y -= GRAVITY3 * dt;
|
|
90767
91918
|
body.mesh.position.addScaledVector(body.velocity, dt);
|
|
90768
91919
|
body.mesh.rotation.x += body.spin.x * dt;
|
|
90769
91920
|
body.mesh.rotation.y += body.spin.y * dt;
|
|
@@ -93346,6 +94497,57 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93346
94497
|
return lehmer(mixEventSeed(eventSeed));
|
|
93347
94498
|
}
|
|
93348
94499
|
var SKIN = 5e-3;
|
|
94500
|
+
var Solids = class {
|
|
94501
|
+
constructor() {
|
|
94502
|
+
__publicField3(this, "queries", /* @__PURE__ */ new Map());
|
|
94503
|
+
__publicField3(this, "list", []);
|
|
94504
|
+
__publicField3(this, "hit", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
94505
|
+
}
|
|
94506
|
+
get empty() {
|
|
94507
|
+
return this.list.length === 0;
|
|
94508
|
+
}
|
|
94509
|
+
/** Declares or (with `null`) ends the solids `id` answers for. */
|
|
94510
|
+
set(id, query2) {
|
|
94511
|
+
if (query2) this.queries.set(id, query2);
|
|
94512
|
+
else this.queries.delete(id);
|
|
94513
|
+
this.list = [...this.queries.values()];
|
|
94514
|
+
}
|
|
94515
|
+
clear() {
|
|
94516
|
+
this.queries.clear();
|
|
94517
|
+
this.list = [];
|
|
94518
|
+
}
|
|
94519
|
+
/**
|
|
94520
|
+
* Stops a step that goes into a solid: `out` gets the nearest hit, put back `pad` metres off the surface (never behind where the step began) and
|
|
94521
|
+
* the surface's normal. Answers whether the step was stopped.
|
|
94522
|
+
*/
|
|
94523
|
+
stop(move2, pad, out) {
|
|
94524
|
+
const dx = move2.x1 - move2.x0;
|
|
94525
|
+
const dy = move2.y1 - move2.y0;
|
|
94526
|
+
const dz = move2.z1 - move2.z0;
|
|
94527
|
+
const length2 = Math.hypot(dx, dy, dz);
|
|
94528
|
+
if (!(length2 > 0)) return false;
|
|
94529
|
+
let nearest = Infinity;
|
|
94530
|
+
for (const query2 of this.list) {
|
|
94531
|
+
if (!query2(move2, this.hit)) continue;
|
|
94532
|
+
const reached = ((this.hit.x - move2.x0) * dx + (this.hit.y - move2.y0) * dy + (this.hit.z - move2.z0) * dz) / length2;
|
|
94533
|
+
if (reached >= nearest) continue;
|
|
94534
|
+
nearest = reached;
|
|
94535
|
+
out.x = this.hit.x;
|
|
94536
|
+
out.y = this.hit.y;
|
|
94537
|
+
out.z = this.hit.z;
|
|
94538
|
+
out.nx = this.hit.nx;
|
|
94539
|
+
out.ny = this.hit.ny;
|
|
94540
|
+
out.nz = this.hit.nz;
|
|
94541
|
+
}
|
|
94542
|
+
if (nearest === Infinity) return false;
|
|
94543
|
+
const back2 = Math.min(Math.max(pad, 0) + SKIN, Math.max(nearest, 0));
|
|
94544
|
+
out.x -= dx / length2 * back2;
|
|
94545
|
+
out.y -= dy / length2 * back2;
|
|
94546
|
+
out.z -= dz / length2 * back2;
|
|
94547
|
+
return true;
|
|
94548
|
+
}
|
|
94549
|
+
};
|
|
94550
|
+
var SKIN2 = 5e-3;
|
|
93349
94551
|
var MAX_PAD = 0.45;
|
|
93350
94552
|
function rotation(q) {
|
|
93351
94553
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
@@ -93377,10 +94579,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93377
94579
|
__publicField3(this, "q", new Float64Array(3));
|
|
93378
94580
|
__publicField3(this, "h", new Float64Array(3));
|
|
93379
94581
|
__publicField3(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
94582
|
+
__publicField3(this, "solids", new Solids());
|
|
93380
94583
|
this.random = lehmer(seed);
|
|
93381
94584
|
}
|
|
93382
94585
|
get empty() {
|
|
93383
|
-
return this.list.length === 0;
|
|
94586
|
+
return this.list.length === 0 && this.solids.empty;
|
|
94587
|
+
}
|
|
94588
|
+
/** Declares or (with `null`) ends the host solids `id` answers for (a destruction world's walls): what is carried stops at them and passes only their holes. */
|
|
94589
|
+
solid(id, query2) {
|
|
94590
|
+
this.solids.set(id, query2);
|
|
93384
94591
|
}
|
|
93385
94592
|
get size() {
|
|
93386
94593
|
return this.list.length;
|
|
@@ -93463,6 +94670,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93463
94670
|
return this.confineMove(move2, dt);
|
|
93464
94671
|
}
|
|
93465
94672
|
confineMove(move2, dt) {
|
|
94673
|
+
if (this.confineSpaces(move2, dt)) return true;
|
|
94674
|
+
return !this.solids.empty && this.solids.stop(move2, Math.min(Math.max(0, move2.pad), MAX_PAD), this.out);
|
|
94675
|
+
}
|
|
94676
|
+
confineSpaces(move2, dt) {
|
|
93466
94677
|
const list2 = this.list;
|
|
93467
94678
|
if (list2.length === 0) return false;
|
|
93468
94679
|
const { x0, y0, z0, x1, y1, z1 } = move2;
|
|
@@ -93503,7 +94714,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93503
94714
|
}
|
|
93504
94715
|
}
|
|
93505
94716
|
sign2 = l1[axis2] < 0 ? -1 : 1;
|
|
93506
|
-
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] -
|
|
94717
|
+
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN2, Math.max(-(h[a] - SKIN2), l1[a]));
|
|
93507
94718
|
sign2 = -sign2;
|
|
93508
94719
|
} else {
|
|
93509
94720
|
const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
|
|
@@ -93520,7 +94731,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93520
94731
|
}
|
|
93521
94732
|
}
|
|
93522
94733
|
sign2 = l0[axis2] < 0 ? -1 : 1;
|
|
93523
|
-
l1[axis2] = sign2 * (h[axis2] + bound +
|
|
94734
|
+
l1[axis2] = sign2 * (h[axis2] + bound + SKIN2);
|
|
93524
94735
|
}
|
|
93525
94736
|
const r = s.r;
|
|
93526
94737
|
const out = this.out;
|
|
@@ -93771,6 +94982,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93771
94982
|
y: 0,
|
|
93772
94983
|
z: 0,
|
|
93773
94984
|
r: 0.6,
|
|
94985
|
+
h: 0,
|
|
93774
94986
|
r0: 0.6,
|
|
93775
94987
|
grow: 0,
|
|
93776
94988
|
life: 6,
|
|
@@ -93796,6 +95008,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93796
95008
|
fire.y = init.y ?? 0;
|
|
93797
95009
|
fire.z = init.z ?? 0;
|
|
93798
95010
|
fire.r = init.r ?? 0.6;
|
|
95011
|
+
fire.h = init.h ?? 0;
|
|
93799
95012
|
fire.r0 = init.startRadius ?? fire.r;
|
|
93800
95013
|
fire.grow = init.grow ?? 0;
|
|
93801
95014
|
fire.life = init.life ?? 6;
|
|
@@ -93820,19 +95033,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93820
95033
|
core.trace?.fire?.(fire);
|
|
93821
95034
|
return fire;
|
|
93822
95035
|
}
|
|
95036
|
+
var FLAMES_PER_HEIGHT = 1.5;
|
|
95037
|
+
var SMOKE_PER_HEIGHT = 2;
|
|
93823
95038
|
function positionOf(follow) {
|
|
93824
95039
|
return "position" in follow ? follow.position : follow;
|
|
93825
95040
|
}
|
|
95041
|
+
var heightOf = (fire) => fire.h > 0 ? fire.rng.next() * fire.h : 0;
|
|
95042
|
+
var isBody = (follow) => "radius" in follow && "height" in follow;
|
|
93826
95043
|
function emitFlames(core, fire, radius, dt) {
|
|
93827
95044
|
const random = fire.rng;
|
|
93828
|
-
fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * fire.fade * core.clock.lod;
|
|
95045
|
+
fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * (1 + fire.h * FLAMES_PER_HEIGHT) * fire.fade * core.clock.lod;
|
|
93829
95046
|
while (fire.acc >= 1) {
|
|
93830
95047
|
fire.acc -= 1;
|
|
93831
95048
|
const angle = random.next() * Math.PI * 2;
|
|
93832
95049
|
const distance4 = Math.sqrt(random.next()) * radius;
|
|
93833
95050
|
addPuff(core, random, {
|
|
93834
95051
|
x: fire.x + Math.cos(angle) * distance4,
|
|
93835
|
-
y: fire.y + 0.05,
|
|
95052
|
+
y: fire.y + 0.05 + heightOf(fire),
|
|
93836
95053
|
z: fire.z + Math.sin(angle) * distance4,
|
|
93837
95054
|
vx: random.between(-0.2, 0.2),
|
|
93838
95055
|
vy: random.between(0.6, 1.4),
|
|
@@ -93854,12 +95071,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93854
95071
|
}
|
|
93855
95072
|
function emitSmoke(core, fire, radius, dt) {
|
|
93856
95073
|
const random = fire.rng;
|
|
93857
|
-
fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * fire.fade * core.clock.lod;
|
|
95074
|
+
fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * (1 + fire.h * SMOKE_PER_HEIGHT) * fire.fade * core.clock.lod;
|
|
93858
95075
|
while (fire.smokeAcc >= 1 && core.layers.smoke) {
|
|
93859
95076
|
fire.smokeAcc -= 1;
|
|
93860
95077
|
addPuff(core, random, {
|
|
93861
95078
|
x: fire.x + random.between(-radius, radius) * 0.5,
|
|
93862
|
-
y: fire.y + 0.6 + radius * 0.3,
|
|
95079
|
+
y: fire.y + fire.h + 0.6 + radius * 0.3,
|
|
93863
95080
|
z: fire.z + random.between(-radius, radius) * 0.5,
|
|
93864
95081
|
vy: random.between(0.8, 1.5),
|
|
93865
95082
|
s0: 0.25,
|
|
@@ -93881,7 +95098,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93881
95098
|
if (!(random.next() < dt * 6 * fire.fade && core.layers.shrapnel)) return;
|
|
93882
95099
|
addSpark(core, {
|
|
93883
95100
|
x: fire.x + random.between(-radius, radius) * 0.6,
|
|
93884
|
-
y: fire.y + 0.4,
|
|
95101
|
+
y: fire.y + 0.4 + heightOf(fire),
|
|
93885
95102
|
z: fire.z + random.between(-radius, radius) * 0.6,
|
|
93886
95103
|
vx: random.between(-0.4, 0.4),
|
|
93887
95104
|
vy: random.between(1.5, 3.2),
|
|
@@ -93905,6 +95122,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93905
95122
|
fire.x = point.x + fire.fx;
|
|
93906
95123
|
fire.y = point.y + fire.fy;
|
|
93907
95124
|
fire.z = point.z + fire.fz;
|
|
95125
|
+
if (isBody(fire.follow)) {
|
|
95126
|
+
fire.r = fire.follow.radius;
|
|
95127
|
+
fire.h = fire.follow.height;
|
|
95128
|
+
}
|
|
93908
95129
|
}
|
|
93909
95130
|
const radius = fire.grow ? lerp2(fire.r0, fire.r, Math.min(1, fire.t / fire.grow)) : fire.r;
|
|
93910
95131
|
fire.fade = fire.t < fire.life - 1.5 ? Math.min(1, fire.t * 3) : Math.max(0, (fire.life - fire.t) / 1.5);
|
|
@@ -94393,7 +95614,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94393
95614
|
var BODY_Z2 = BODIES.map(([, z]) => z);
|
|
94394
95615
|
var FACING = BODIES.map(([x, z]) => Math.atan2(-x, -z));
|
|
94395
95616
|
var FUSE = 1.8;
|
|
94396
|
-
var
|
|
95617
|
+
var GRAVITY4 = 9.8;
|
|
94397
95618
|
var FLOOR = 0.07;
|
|
94398
95619
|
var BOUNCE = -0.4;
|
|
94399
95620
|
var SIDE_LOSS = 0.5;
|
|
@@ -94423,7 +95644,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94423
95644
|
],
|
|
94424
95645
|
tick: [
|
|
94425
95646
|
when(lt(TIME, FUSE), [
|
|
94426
|
-
set("vy", sub(variable("vy"), mul(
|
|
95647
|
+
set("vy", sub(variable("vy"), mul(GRAVITY4, DELTA))),
|
|
94427
95648
|
set("px", add(variable("px"), mul(variable("vx"), DELTA))),
|
|
94428
95649
|
set("py", add(variable("py"), mul(variable("vy"), DELTA))),
|
|
94429
95650
|
set("pz", add(variable("pz"), mul(variable("vz"), DELTA))),
|
|
@@ -97497,6 +98718,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97497
98718
|
screen2.flashDecay = 0.5;
|
|
97498
98719
|
}
|
|
97499
98720
|
}
|
|
98721
|
+
var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
98722
|
+
function bornFrom(core, puff3, ox, oy, oz) {
|
|
98723
|
+
const confiner = core.confiner;
|
|
98724
|
+
if (confiner.empty) return;
|
|
98725
|
+
BIRTH.x0 = ox;
|
|
98726
|
+
BIRTH.y0 = oy;
|
|
98727
|
+
BIRTH.z0 = oz;
|
|
98728
|
+
BIRTH.x1 = puff3.x;
|
|
98729
|
+
BIRTH.y1 = puff3.y;
|
|
98730
|
+
BIRTH.z1 = puff3.z;
|
|
98731
|
+
BIRTH.pad = puff3.s0 * PAD_OF_SIZE;
|
|
98732
|
+
if (!confiner.confineMove(BIRTH, 0)) return;
|
|
98733
|
+
const out = confiner.out;
|
|
98734
|
+
puff3.x = out.x;
|
|
98735
|
+
puff3.y = out.y;
|
|
98736
|
+
puff3.z = out.z;
|
|
98737
|
+
slideInto(out, puff3);
|
|
98738
|
+
}
|
|
97500
98739
|
function composeFireballs(context) {
|
|
97501
98740
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
97502
98741
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -97513,7 +98752,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97513
98752
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life);
|
|
97514
98753
|
const h0 = random.between(1.05, 1.35) * heat;
|
|
97515
98754
|
const hl = fuel ? random.between(0.8, 1.4) * (def.heatLifeScale ?? 1) : random.between(0.22, 0.42);
|
|
97516
|
-
addPuff(core, random, {
|
|
98755
|
+
const fireball = addPuff(core, random, {
|
|
97517
98756
|
x: x + d.x * size * 0.15,
|
|
97518
98757
|
y: y + size * 0.25 + d.y * size * 0.1,
|
|
97519
98758
|
z: z + d.z * size * 0.15,
|
|
@@ -97532,6 +98771,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97532
98771
|
color: context.smokeColor,
|
|
97533
98772
|
kind: 0
|
|
97534
98773
|
});
|
|
98774
|
+
bornFrom(core, fireball, x, y, z);
|
|
97535
98775
|
}
|
|
97536
98776
|
}
|
|
97537
98777
|
function composeSmoke(context) {
|
|
@@ -97545,7 +98785,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97545
98785
|
const s1 = size * random.between(0.55, 0.85);
|
|
97546
98786
|
const sg = size * random.between(0.18, 0.3);
|
|
97547
98787
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life * 1.1);
|
|
97548
|
-
addPuff(core, random, {
|
|
98788
|
+
const smoke = addPuff(core, random, {
|
|
97549
98789
|
x: x + d.x * size * 0.6,
|
|
97550
98790
|
y: y + size * 0.4 + d.y * size * 0.5,
|
|
97551
98791
|
z: z + d.z * size * 0.6,
|
|
@@ -97564,6 +98804,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97564
98804
|
color: context.smokeColor,
|
|
97565
98805
|
kind: def.smoke.kind ?? 0
|
|
97566
98806
|
});
|
|
98807
|
+
bornFrom(core, smoke, x, y, z);
|
|
97567
98808
|
}
|
|
97568
98809
|
}
|
|
97569
98810
|
function composeShock(context) {
|
|
@@ -97588,7 +98829,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97588
98829
|
const s1 = size * random.between(0.5, 0.8);
|
|
97589
98830
|
const sg = size * random.between(0.2, 0.35);
|
|
97590
98831
|
const life = random.between(2.2, 4);
|
|
97591
|
-
addPuff(core, random, {
|
|
98832
|
+
const dust = addPuff(core, random, {
|
|
97592
98833
|
x: x + Math.cos(angle) * 0.3,
|
|
97593
98834
|
y: 0.15,
|
|
97594
98835
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -97605,6 +98846,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97605
98846
|
color: color2,
|
|
97606
98847
|
kind: 1
|
|
97607
98848
|
});
|
|
98849
|
+
bornFrom(core, dust, x, 0.15, z);
|
|
97608
98850
|
}
|
|
97609
98851
|
}
|
|
97610
98852
|
function coneAngle(context) {
|
|
@@ -99676,6 +100918,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99676
100918
|
});
|
|
99677
100919
|
const core = {
|
|
99678
100920
|
profile,
|
|
100921
|
+
confiner: enclosures,
|
|
99679
100922
|
puffs: createPuffPool(profile.puffs),
|
|
99680
100923
|
sparks: createSparkPool(profile.sparks),
|
|
99681
100924
|
glows: createGlowPool(profile.glows),
|
|
@@ -99784,10 +101027,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99784
101027
|
},
|
|
99785
101028
|
fire(fireOptions) {
|
|
99786
101029
|
const handle = ++handles.next;
|
|
99787
|
-
const { point, offset, seed, radius, smokeColor, ...rest2 } = fireOptions;
|
|
101030
|
+
const { point, offset, seed, radius, height, smokeColor, ...rest2 } = fireOptions;
|
|
99788
101031
|
addFire(core, streamOf(seed), {
|
|
99789
101032
|
...rest2,
|
|
99790
101033
|
r: radius,
|
|
101034
|
+
...height !== void 0 ? { h: height } : {},
|
|
99791
101035
|
x: point[0],
|
|
99792
101036
|
y: point[1],
|
|
99793
101037
|
z: point[2],
|
|
@@ -99815,6 +101059,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99815
101059
|
enclose(id, enclosure) {
|
|
99816
101060
|
enclosures.set(id, enclosure);
|
|
99817
101061
|
},
|
|
101062
|
+
solid(id, query2) {
|
|
101063
|
+
enclosures.solid(id, query2);
|
|
101064
|
+
},
|
|
99818
101065
|
enclosures: () => enclosures,
|
|
99819
101066
|
stop(handle) {
|
|
99820
101067
|
player?.stop(handle);
|
|
@@ -99922,7 +101169,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99922
101169
|
}
|
|
99923
101170
|
var DEGREES = 180 / Math.PI;
|
|
99924
101171
|
|
|
99925
|
-
// ../game-vfx-three/dist/chunk-
|
|
101172
|
+
// ../game-vfx-three/dist/chunk-KIZDMENO.js
|
|
99926
101173
|
var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
|
|
99927
101174
|
void main(){vec3 R=vec3(viewMatrix[0][0],viewMatrix[1][0],viewMatrix[2][0]);vec3 Up=vec3(viewMatrix[0][1],viewMatrix[1][1],viewMatrix[2][1]);
|
|
99928
101175
|
vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
|
|
@@ -99938,6 +101185,59 @@ float vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);
|
|
|
99938
101185
|
`;
|
|
99939
101186
|
var PUFF_VERTEX = `${GL_NOISE}
|
|
99940
101187
|
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
|
|
101188
|
+
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
101189
|
+
void main(){
|
|
101190
|
+
vec3 p=position;
|
|
101191
|
+
float s=aD.z;
|
|
101192
|
+
float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
|
|
101193
|
+
p*=0.78+0.5*n;
|
|
101194
|
+
float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;
|
|
101195
|
+
vL=p;
|
|
101196
|
+
vec3 wp=aP.xyz+p*aP.w;
|
|
101197
|
+
vWP=wp;vD=aD;vC=aC;
|
|
101198
|
+
gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
|
|
101199
|
+
}`;
|
|
101200
|
+
var PUFF_FRAGMENT = `${GL_NOISE}
|
|
101201
|
+
uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
|
|
101202
|
+
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
101203
|
+
vec3 L(vec3 c){return pow(c,vec3(2.2));}
|
|
101204
|
+
vec3 ramp(float h){
|
|
101205
|
+
vec3 c0=L(vec3(.36,.07,.03)),c1=L(vec3(.76,.21,.1)),c2=L(vec3(1.,.54,.16)),c3=L(vec3(1.,.83,.42)),c4=L(vec3(1.,.96,.84));
|
|
101206
|
+
if(h<.25)return mix(c0,c1,h/.25);
|
|
101207
|
+
if(h<.5)return mix(c1,c2,(h-.25)/.25);
|
|
101208
|
+
if(h<.8)return mix(c2,c3,(h-.5)/.3);
|
|
101209
|
+
return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
|
|
101210
|
+
}
|
|
101211
|
+
void main(){
|
|
101212
|
+
vec3 N=normalize(cross(dFdx(vWP),dFdy(vWP)));
|
|
101213
|
+
float age=vD.x,heat=vD.y,kind=vD.w;
|
|
101214
|
+
float n=vn(vL*2.4+vD.z*13.0);
|
|
101215
|
+
float diss=smoothstep(.5,1.,age);
|
|
101216
|
+
if(n<diss*1.08-.04)discard;
|
|
101217
|
+
float lam=max(dot(N,uLight),0.);
|
|
101218
|
+
float band=lam>.55?1.:lam>.15?.68:.42;
|
|
101219
|
+
// soot: a dark smoke still scatters some light, so it never goes flat black, and its rim takes the sky so its volume reads (only the dark puffs; the rest as the Lab)
|
|
101220
|
+
float dark=1.-smoothstep(.02,.12,dot(vC,vec3(.2126,.7152,.0722)));
|
|
101221
|
+
vec3 alb=max(vC,vec3(.055)*dark);
|
|
101222
|
+
vec3 col=alb*(vec3(.5,.56,.7)*band*1.05+vec3(.2,.19,.18)+uGround*(.4-.4*N.y));
|
|
101223
|
+
float rim=pow(1.-clamp(abs(dot(N,normalize(cameraPosition-vWP))),0.,1.),2.);
|
|
101224
|
+
col+=dark*rim*(uSky*.9+alb);
|
|
101225
|
+
vec3 tg=uGlowPos-vWP;float dg=length(tg)+.001;
|
|
101226
|
+
float gi=uGlowI/(1.+dg*dg*.05)*(.3+.7*max(dot(N,tg/dg),0.));
|
|
101227
|
+
col+=uGlowCol*gi*alb*1.6;
|
|
101228
|
+
float h=heat*(.72+.56*n)+heat*(-N.y)*.18;
|
|
101229
|
+
if(h>.05){
|
|
101230
|
+
float hq=floor(h*5.+.5)/5.;
|
|
101231
|
+
vec3 fc=ramp(clamp(hq,0.,1.2))*(1.1+3.1*hq);
|
|
101232
|
+
col=mix(col,fc,smoothstep(.04,.2,h));
|
|
101233
|
+
}
|
|
101234
|
+
if(kind>2.5&&kind<3.5){col+=vec3(.02,.025,.03);}
|
|
101235
|
+
gl_FragColor=vec4(col,1.);
|
|
101236
|
+
#include <tonemapping_fragment>
|
|
101237
|
+
#include <colorspace_fragment>
|
|
101238
|
+
}`;
|
|
101239
|
+
var SOFT_PUFF_VERTEX = `${GL_NOISE}
|
|
101240
|
+
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
|
|
99941
101241
|
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
99942
101242
|
void main(){
|
|
99943
101243
|
vec3 p=position;
|
|
@@ -99951,7 +101251,7 @@ void main(){
|
|
|
99951
101251
|
vWP=wp;vD=aD;vC=aC;
|
|
99952
101252
|
gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
|
|
99953
101253
|
}`;
|
|
99954
|
-
var
|
|
101254
|
+
var SOFT_PUFF_FRAGMENT = `${GL_NOISE}
|
|
99955
101255
|
uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
|
|
99956
101256
|
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
99957
101257
|
vec3 L(vec3 c){return pow(c,vec3(2.2));}
|
|
@@ -100026,11 +101326,11 @@ void main(){
|
|
|
100026
101326
|
function dynamic(THREE, array, size) {
|
|
100027
101327
|
return new THREE.InstancedBufferAttribute(array, size).setUsage(THREE.DynamicDrawUsage);
|
|
100028
101328
|
}
|
|
100029
|
-
var PUFF_DETAIL = 2;
|
|
100030
|
-
function createPuffLayer(THREE, pool, uniforms) {
|
|
101329
|
+
var PUFF_DETAIL = { faceted: 1, soft: 2 };
|
|
101330
|
+
function createPuffLayer(THREE, pool, uniforms, style = "faceted") {
|
|
100031
101331
|
const capacity = pool.capacity;
|
|
100032
101332
|
const geometry = new THREE.InstancedBufferGeometry();
|
|
100033
|
-
geometry.setAttribute("position", new THREE.IcosahedronGeometry(1, PUFF_DETAIL).getAttribute("position"));
|
|
101333
|
+
geometry.setAttribute("position", new THREE.IcosahedronGeometry(1, PUFF_DETAIL[style]).getAttribute("position"));
|
|
100034
101334
|
const a = new Float32Array(capacity * 4);
|
|
100035
101335
|
const d = new Float32Array(capacity * 4);
|
|
100036
101336
|
const c = new Float32Array(capacity * 3);
|
|
@@ -100039,7 +101339,7 @@ void main(){
|
|
|
100039
101339
|
geometry.setAttribute("aD", attributes[1]);
|
|
100040
101340
|
geometry.setAttribute("aC", attributes[2]);
|
|
100041
101341
|
geometry.instanceCount = 0;
|
|
100042
|
-
const material = new THREE.ShaderMaterial({ uniforms, vertexShader: PUFF_VERTEX, fragmentShader: PUFF_FRAGMENT, transparent: true, depthWrite: false });
|
|
101342
|
+
const material = style === "faceted" ? new THREE.ShaderMaterial({ uniforms, vertexShader: PUFF_VERTEX, fragmentShader: PUFF_FRAGMENT }) : new THREE.ShaderMaterial({ uniforms, vertexShader: SOFT_PUFF_VERTEX, fragmentShader: SOFT_PUFF_FRAGMENT, transparent: true, depthWrite: false });
|
|
100043
101343
|
const mesh3 = new THREE.Mesh(geometry, material);
|
|
100044
101344
|
mesh3.name = "vfx-puffs";
|
|
100045
101345
|
mesh3.frustumCulled = false;
|
|
@@ -100702,6 +102002,7 @@ void main(){
|
|
|
100702
102002
|
}
|
|
100703
102003
|
};
|
|
100704
102004
|
}
|
|
102005
|
+
var SHOWN_FIELDS = 6;
|
|
100705
102006
|
var clamp5 = (value, min2, max2) => value < min2 ? min2 : value > max2 ? max2 : value;
|
|
100706
102007
|
function layer2(container, name, blend) {
|
|
100707
102008
|
const element = container.ownerDocument.createElement("div");
|
|
@@ -100719,8 +102020,20 @@ void main(){
|
|
|
100719
102020
|
const sides = layer2(container, "sides");
|
|
100720
102021
|
const gas = layer2(container, "gas");
|
|
100721
102022
|
const elements = [flash2, white, red, sides, gas];
|
|
102023
|
+
const shown = new Float64Array(SHOWN_FIELDS).fill(Number.NaN);
|
|
102024
|
+
const isShown2 = (state) => {
|
|
102025
|
+
const same = shown[0] === state.flash && shown[1] === state.white && shown[2] === state.red && shown[3] === state.directionLeft && shown[4] === state.directionRight && shown[5] === state.gas;
|
|
102026
|
+
shown[0] = state.flash;
|
|
102027
|
+
shown[1] = state.white;
|
|
102028
|
+
shown[2] = state.red;
|
|
102029
|
+
shown[3] = state.directionLeft;
|
|
102030
|
+
shown[4] = state.directionRight;
|
|
102031
|
+
shown[5] = state.gas;
|
|
102032
|
+
return same;
|
|
102033
|
+
};
|
|
100722
102034
|
return {
|
|
100723
102035
|
update(state) {
|
|
102036
|
+
if (isShown2(state)) return;
|
|
100724
102037
|
flash2.style.opacity = clamp5(state.flash, 0, 1).toFixed(3);
|
|
100725
102038
|
white.style.opacity = "1";
|
|
100726
102039
|
white.style.background = `rgba(235,240,255,${clamp5(state.white, 0, 1).toFixed(2)})`;
|
|
@@ -101361,7 +102674,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
101361
102674
|
uGlowI: { value: 0 },
|
|
101362
102675
|
uTime: { value: 0 }
|
|
101363
102676
|
};
|
|
101364
|
-
const puffs = createPuffLayer(THREE, pools.puffs, uniforms);
|
|
102677
|
+
const puffs = createPuffLayer(THREE, pools.puffs, uniforms, options.puffStyle ?? "faceted");
|
|
101365
102678
|
const sparks2 = createSparkLayer(THREE, pools.sparks);
|
|
101366
102679
|
const glows = createGlowLayer(THREE, pools.glows);
|
|
101367
102680
|
const rockGeometry = new THREE.DodecahedronGeometry(0.5, 0);
|
|
@@ -105287,7 +106600,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
105287
106600
|
var AFTERMATH_DELAY = 2;
|
|
105288
106601
|
var SHOOTER = "pistol_9mm";
|
|
105289
106602
|
var AIM_HEIGHT = 0.2;
|
|
105290
|
-
var
|
|
106603
|
+
var GRAVITY5 = 9.81;
|
|
105291
106604
|
var REPORTED_OBJECTS = ["fridge", "kitchen_cabinet_base", "stove", "camp_table"];
|
|
105292
106605
|
var RING_SEGMENTS = 128;
|
|
105293
106606
|
var WALL_ID = "target_wall";
|
|
@@ -105436,7 +106749,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
105436
106749
|
for (const shell of shells) {
|
|
105437
106750
|
if (shell.landed) continue;
|
|
105438
106751
|
shell.age += dt;
|
|
105439
|
-
shell.velocity[1] -=
|
|
106752
|
+
shell.velocity[1] -= GRAVITY5 * dt;
|
|
105440
106753
|
for (let axis2 = 0; axis2 < 3; axis2++) shell.position[axis2] = shell.position[axis2] + shell.velocity[axis2] * dt;
|
|
105441
106754
|
const ground = host.groundAt(shell.position[0], shell.position[2]) + 0.18;
|
|
105442
106755
|
if (shell.position[1] <= ground && shell.velocity[1] < 0) {
|