@adatechnology/game-weapons-three 0.29.7 → 0.29.9
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 +1944 -374
- package/dist/index.global.js.map +1 -1
- package/package.json +13 -13
package/dist/index.global.js
CHANGED
|
@@ -432,12 +432,12 @@ var GameWeaponsThree = (() => {
|
|
|
432
432
|
};
|
|
433
433
|
var STAGE_EVENT = "stage";
|
|
434
434
|
var scaleClip = (clip, duration) => {
|
|
435
|
-
const
|
|
435
|
+
const factor2 = clip.duration > 0 ? duration / clip.duration : 1;
|
|
436
436
|
return {
|
|
437
437
|
...clip,
|
|
438
438
|
duration,
|
|
439
|
-
keys: clip.keys.map((key2) => ({ ...key2, t: key2.t *
|
|
440
|
-
...clip.events ? { events: clip.events.map((event) => ({ ...event, t: event.t *
|
|
439
|
+
keys: clip.keys.map((key2) => ({ ...key2, t: key2.t * factor2 })),
|
|
440
|
+
...clip.events ? { events: clip.events.map((event) => ({ ...event, t: event.t * factor2 })) } : {}
|
|
441
441
|
};
|
|
442
442
|
};
|
|
443
443
|
var ZERO = [0, 0, 0];
|
|
@@ -15397,9 +15397,9 @@ var GameWeaponsThree = (() => {
|
|
|
15397
15397
|
}
|
|
15398
15398
|
};
|
|
15399
15399
|
var defaultFaultChance = (context) => {
|
|
15400
|
-
const
|
|
15400
|
+
const factor2 = context.def.action.kind === "firearm" ? context.def.action.faultFactor ?? 1 : 1;
|
|
15401
15401
|
const overheat = 1 + Math.max(0, context.heat - DEFAULT_HEAT.faultFrom) / DEFAULT_HEAT.faultSpan;
|
|
15402
|
-
return context.condition.faultChance *
|
|
15402
|
+
return context.condition.faultChance * factor2 * overheat;
|
|
15403
15403
|
};
|
|
15404
15404
|
var DEFAULT_RULES = {
|
|
15405
15405
|
faults: true,
|
|
@@ -15479,11 +15479,11 @@ var GameWeaponsThree = (() => {
|
|
|
15479
15479
|
var STILL_STEPS = 2;
|
|
15480
15480
|
var STILL_SHARE = 0.05;
|
|
15481
15481
|
var bounce = (velocity2, normal, ground, rules) => {
|
|
15482
|
-
const
|
|
15483
|
-
if (
|
|
15482
|
+
const along3 = dot(velocity2, normal);
|
|
15483
|
+
if (along3 >= 0) return velocity2;
|
|
15484
15484
|
const restitution = ground ? rules.groundRestitution : rules.wallRestitution;
|
|
15485
15485
|
const friction = ground ? rules.groundFriction : 1;
|
|
15486
|
-
const normalPart = [normal[0] *
|
|
15486
|
+
const normalPart = [normal[0] * along3, normal[1] * along3, normal[2] * along3];
|
|
15487
15487
|
return [
|
|
15488
15488
|
(velocity2[0] - normalPart[0]) * friction - normalPart[0] * restitution,
|
|
15489
15489
|
(velocity2[1] - normalPart[1]) * friction - normalPart[1] * restitution,
|
|
@@ -15543,12 +15543,12 @@ var GameWeaponsThree = (() => {
|
|
|
15543
15543
|
isTriggeredBy(trigger) {
|
|
15544
15544
|
return this.triggers.has(trigger);
|
|
15545
15545
|
}
|
|
15546
|
-
step(dt,
|
|
15546
|
+
step(dt, probe2) {
|
|
15547
15547
|
const events = [];
|
|
15548
15548
|
if (this.isDone) return events;
|
|
15549
15549
|
const seconds = Math.max(0, dt);
|
|
15550
15550
|
const slice = this.fuseLeft === void 0 ? seconds : Math.min(seconds, this.fuseLeft);
|
|
15551
|
-
this.fly(slice,
|
|
15551
|
+
this.fly(slice, probe2, events);
|
|
15552
15552
|
if (this.isDone) return events;
|
|
15553
15553
|
if (this.isLaunched && this.isSpent()) {
|
|
15554
15554
|
events.push(this.detonate(this.clock >= this.rules.selfDestructSeconds ? "timer" : "impact"));
|
|
@@ -15574,7 +15574,7 @@ var GameWeaponsThree = (() => {
|
|
|
15574
15574
|
if (this.clock >= this.rules.selfDestructSeconds) return true;
|
|
15575
15575
|
return !this.moves() || this.stillSteps >= STILL_STEPS;
|
|
15576
15576
|
}
|
|
15577
|
-
fly(seconds,
|
|
15577
|
+
fly(seconds, probe2, events) {
|
|
15578
15578
|
if (seconds <= 0 || !this.moves()) {
|
|
15579
15579
|
this.clock += Math.max(0, seconds);
|
|
15580
15580
|
return;
|
|
@@ -15582,7 +15582,7 @@ var GameWeaponsThree = (() => {
|
|
|
15582
15582
|
const start = this.position;
|
|
15583
15583
|
this.velocity = [this.velocity[0], this.velocity[1] - this.rules.gravity * seconds, this.velocity[2]];
|
|
15584
15584
|
const next = [this.position[0] + this.velocity[0] * seconds, this.position[1] + this.velocity[1] * seconds, this.position[2] + this.velocity[2] * seconds];
|
|
15585
|
-
const hit =
|
|
15585
|
+
const hit = probe2?.(this.position, next) ?? null;
|
|
15586
15586
|
const target = hit ? hit.point : next;
|
|
15587
15587
|
const moved = distance(this.position, target);
|
|
15588
15588
|
const planned = distance(this.position, next);
|
|
@@ -16621,9 +16621,9 @@ var GameWeaponsThree = (() => {
|
|
|
16621
16621
|
if (this.isWorking()) return false;
|
|
16622
16622
|
if (this.underActive && this.under) return this.under.reload(request);
|
|
16623
16623
|
const base2 = this.action;
|
|
16624
|
-
const
|
|
16625
|
-
const isFast =
|
|
16626
|
-
if (isFast && base2.kind === "firearm") this.action = { ...base2, reload: base2.reload *
|
|
16624
|
+
const factor2 = this.load.secondReloadFactor;
|
|
16625
|
+
const isFast = factor2 !== 1 && this.reloadCount % 2 === 1 && base2.kind === "firearm";
|
|
16626
|
+
if (isFast && base2.kind === "firearm") this.action = { ...base2, reload: base2.reload * factor2, ...base2.timings ? { timings: { ...base2.timings, reload: base2.timings.reload * factor2, ...base2.timings.reloadEmpty === void 0 ? {} : { reloadEmpty: base2.timings.reloadEmpty * factor2 } } } : {} };
|
|
16627
16627
|
const started = super.reload(request);
|
|
16628
16628
|
this.action = base2;
|
|
16629
16629
|
if (started) this.reloadCount += 1;
|
|
@@ -16693,9 +16693,9 @@ var GameWeaponsThree = (() => {
|
|
|
16693
16693
|
}
|
|
16694
16694
|
/** The rules with the chance of a fault scaled by the accessories (a drum magazine jams more); the very rules when nothing scales it. */
|
|
16695
16695
|
faultRules() {
|
|
16696
|
-
const
|
|
16697
|
-
if (
|
|
16698
|
-
return { ...this.rules, faultChance: (context) => this.rules.faultChance(context) *
|
|
16696
|
+
const factor2 = this.load.faultFactor;
|
|
16697
|
+
if (factor2 === 1) return this.rules;
|
|
16698
|
+
return { ...this.rules, faultChance: (context) => this.rules.faultChance(context) * factor2 };
|
|
16699
16699
|
}
|
|
16700
16700
|
jam(fault, at4, res) {
|
|
16701
16701
|
this._fault = fault;
|
|
@@ -19421,7 +19421,7 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
19421
19421
|
const found = collect(list2);
|
|
19422
19422
|
const keepRoots = options.keep === void 0 ? [] : Array.isArray(options.keep) ? options.keep : [options.keep];
|
|
19423
19423
|
const releasing = new Set(list2);
|
|
19424
|
-
for (const
|
|
19424
|
+
for (const keep2 of keepRoots) {
|
|
19425
19425
|
const walk = (o) => {
|
|
19426
19426
|
if (releasing.has(o)) return;
|
|
19427
19427
|
const owner = o;
|
|
@@ -19437,7 +19437,7 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
19437
19437
|
}
|
|
19438
19438
|
for (const c of o.children) walk(c);
|
|
19439
19439
|
};
|
|
19440
|
-
walk(
|
|
19440
|
+
walk(keep2);
|
|
19441
19441
|
}
|
|
19442
19442
|
for (const g of found.geometries) {
|
|
19443
19443
|
if (shared(g)) continue;
|
|
@@ -19459,14 +19459,14 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
19459
19459
|
}
|
|
19460
19460
|
function discardObject3D(objects, options = {}) {
|
|
19461
19461
|
const list2 = Array.isArray(objects) ? objects : [objects];
|
|
19462
|
-
const
|
|
19462
|
+
const keep2 = options.keep === void 0 ? [] : Array.isArray(options.keep) ? [...options.keep] : [options.keep];
|
|
19463
19463
|
for (const object2 of list2) {
|
|
19464
19464
|
let top = object2;
|
|
19465
19465
|
while (top.parent) top = top.parent;
|
|
19466
19466
|
object2.removeFromParent();
|
|
19467
|
-
if (top !== object2 && !
|
|
19467
|
+
if (top !== object2 && !keep2.includes(top)) keep2.push(top);
|
|
19468
19468
|
}
|
|
19469
|
-
return releaseObject3D(list2, { keep });
|
|
19469
|
+
return releaseObject3D(list2, { keep: keep2 });
|
|
19470
19470
|
}
|
|
19471
19471
|
function isMesh(o) {
|
|
19472
19472
|
return !!o && o.isMesh === true;
|
|
@@ -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);
|
|
@@ -21865,8 +21865,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21865
21865
|
const sorted = [0, 1, 2].sort((x, y) => dims[x] - dims[y]);
|
|
21866
21866
|
const t = sorted[0];
|
|
21867
21867
|
const [u, v] = [sorted[1], sorted[2]].sort((x, y) => x - y);
|
|
21868
|
-
const
|
|
21869
|
-
const across2 =
|
|
21868
|
+
const along3 = dims[u] >= dims[v] ? u : v;
|
|
21869
|
+
const across2 = along3 === u ? v : u;
|
|
21870
21870
|
const layers = clamp(Math.round(dims[t] / PLY / 2), 2, 3);
|
|
21871
21871
|
const pitch = dims[t] / layers;
|
|
21872
21872
|
const th = Math.min(pitch, PLY_SHEET);
|
|
@@ -21880,7 +21880,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21880
21880
|
if (out.length >= limit) return out;
|
|
21881
21881
|
if (rnd2() < 0.35) {
|
|
21882
21882
|
const strand = cell.s[across2] * (0.15 + 0.2 * rnd2());
|
|
21883
|
-
out.push({ center: cell.c, size: [cell.s[
|
|
21883
|
+
out.push({ center: cell.c, size: [cell.s[along3], strand, th * 0.7], q: frame(along3, across2, t), shape: "splinter", weight: cell.s[along3] * strand * th });
|
|
21884
21884
|
} else {
|
|
21885
21885
|
out.push({ center: cell.c, size: [cell.s[u], cell.s[v], th], q: frame(u, v, t, (rnd2() - 0.5) * 0.5), shape: "scrap", weight: cell.s[u] * cell.s[v] * th });
|
|
21886
21886
|
}
|
|
@@ -21993,8 +21993,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21993
21993
|
const share = Math.max(1, Math.round(inp.maxFragments * volumes[i] / total));
|
|
21994
21994
|
const hit = [inp.hit[0] - solid2.center[0], inp.hit[1] - solid2.center[1], inp.hit[2] - solid2.center[2]];
|
|
21995
21995
|
const { cut, solids: _all, ...rest2 } = inp;
|
|
21996
|
-
const
|
|
21997
|
-
const inside3 = cut && Math.abs(cut.at - solid2.center[
|
|
21996
|
+
const along3 = cut ? [0, 1, 2].sort((a, b) => solid2.size[b] - solid2.size[a])[0] : -1;
|
|
21997
|
+
const inside3 = cut && Math.abs(cut.at - solid2.center[along3]) < solid2.size[along3] / 2 ? { cut: { at: cut.at - solid2.center[along3], gap: cut.gap } } : {};
|
|
21998
21998
|
for (const f of planBox({ ...rest2, ...inside3, dims: [solid2.size[0], solid2.size[1], solid2.size[2]], hit, maxFragments: share, thickness: Math.min(inp.thickness, Math.min(...solid2.size)) })) {
|
|
21999
21999
|
out.push({ ...f, center: [f.center[0] + solid2.center[0], f.center[1] + solid2.center[1], f.center[2] + solid2.center[2]] });
|
|
22000
22000
|
}
|
|
@@ -22212,11 +22212,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22212
22212
|
lo0 = Math.min(lo0, cell.center[u] - cell.size[u] / 2);
|
|
22213
22213
|
lo1 = Math.min(lo1, cell.center[v] - cell.size[v] / 2);
|
|
22214
22214
|
}
|
|
22215
|
-
let
|
|
22215
|
+
let along3 = 1, up = 1;
|
|
22216
22216
|
for (let grow2 = 0; ; grow2++) {
|
|
22217
22217
|
const bins = /* @__PURE__ */ new Map();
|
|
22218
22218
|
for (const cell of cells) {
|
|
22219
|
-
const key2 = `${Math.floor((cell.center[u] - lo0) / (
|
|
22219
|
+
const key2 = `${Math.floor((cell.center[u] - lo0) / (along3 * unit[0]))}:${Math.floor((cell.center[v] - lo1) / (up * unit[1]))}`;
|
|
22220
22220
|
const bin2 = bins.get(key2) ?? { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] };
|
|
22221
22221
|
for (let k = 0; k < 3; k++) {
|
|
22222
22222
|
bin2.lo[k] = Math.min(bin2.lo[k], cell.center[k] - cell.size[k] / 2);
|
|
@@ -22228,7 +22228,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22228
22228
|
return [...bins.values()].map(({ lo, hi }) => ({ center: [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2], size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]] }));
|
|
22229
22229
|
}
|
|
22230
22230
|
if (grow2 % 2 === 0) up++;
|
|
22231
|
-
else
|
|
22231
|
+
else along3++;
|
|
22232
22232
|
}
|
|
22233
22233
|
};
|
|
22234
22234
|
var PART_GRID_MIN_PARTS = 64;
|
|
@@ -22415,14 +22415,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22415
22415
|
const step = count > 1 && room / (count - 1) < spacing ? room / (count - 1) : spacing;
|
|
22416
22416
|
return Array.from({ length: count }, (_, i) => (i - (count - 1) / 2) * step);
|
|
22417
22417
|
};
|
|
22418
|
-
var bar = (axis2,
|
|
22418
|
+
var bar = (axis2, along3, fixed2) => {
|
|
22419
22419
|
const a = [0, 0, 0], b = [0, 0, 0];
|
|
22420
22420
|
for (const [index, value] of fixed2) {
|
|
22421
22421
|
a[index] = value;
|
|
22422
22422
|
b[index] = value;
|
|
22423
22423
|
}
|
|
22424
|
-
a[axis2] = -
|
|
22425
|
-
b[axis2] =
|
|
22424
|
+
a[axis2] = -along3;
|
|
22425
|
+
b[axis2] = along3;
|
|
22426
22426
|
return [a, b];
|
|
22427
22427
|
};
|
|
22428
22428
|
var isMember = (dims, role) => {
|
|
@@ -23254,7 +23254,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23254
23254
|
};
|
|
23255
23255
|
var analyzeWind = (parts2, c, ground) => {
|
|
23256
23256
|
const [dx, dz] = c.direction;
|
|
23257
|
-
const
|
|
23257
|
+
const along3 = (p) => {
|
|
23258
23258
|
const cx = (p.min[0] + p.max[0]) / 2, cz = (p.min[2] + p.max[2]) / 2;
|
|
23259
23259
|
const hx = (p.max[0] - p.min[0]) / 2, hz2 = (p.max[2] - p.min[2]) / 2;
|
|
23260
23260
|
return {
|
|
@@ -23264,7 +23264,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23264
23264
|
dv: 2 * (Math.abs(dz) * hx + Math.abs(dx) * hz2)
|
|
23265
23265
|
};
|
|
23266
23266
|
};
|
|
23267
|
-
const g = parts2.map(
|
|
23267
|
+
const g = parts2.map(along3);
|
|
23268
23268
|
let topY = ground;
|
|
23269
23269
|
let resists = false;
|
|
23270
23270
|
for (const p of parts2) {
|
|
@@ -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",
|
|
@@ -25019,6 +25049,942 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25019
25049
|
if (ductility >= 0.3) return 1;
|
|
25020
25050
|
return (1 + 4 * (0.3 - ductility) / 0.3) * Math.min(25, Math.max(1, (0.02 / Math.max(thickness, 1e-4)) ** 2));
|
|
25021
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 SAG_STATIONS = BEAM_PIECES + 1;
|
|
25182
|
+
var SLENDER = 4;
|
|
25183
|
+
var MAX_DOF = 1500;
|
|
25184
|
+
var MECHANISM = 0.5;
|
|
25185
|
+
var FOOT_FRICTION = 0.4;
|
|
25186
|
+
var UPRIGHT = 0.9;
|
|
25187
|
+
var SOFT = 1e-11;
|
|
25188
|
+
var GRAVITY2 = 9.81;
|
|
25189
|
+
var EDGE_D = 4;
|
|
25190
|
+
var ROW_D = 5;
|
|
25191
|
+
var END_D = 10;
|
|
25192
|
+
var THREAD_D = 6;
|
|
25193
|
+
var isWood = (m) => !!m.tags && m.tags.includes("wood");
|
|
25194
|
+
function fastenerStiffness(kind, a, b) {
|
|
25195
|
+
const f = JOINT_FASTENERS[kind];
|
|
25196
|
+
if (!f) return null;
|
|
25197
|
+
const woods = [a, b].filter(isWood);
|
|
25198
|
+
if (woods.length === 0) return null;
|
|
25199
|
+
const density = woods.length === 2 ? Math.sqrt(a.density * b.density) : woods[0].density;
|
|
25200
|
+
const d = f.diameterMm;
|
|
25201
|
+
const perMm = f.lateral === "predrilled" ? density ** 1.5 * d / 23 : density ** 1.5 * d ** 0.8 / 30;
|
|
25202
|
+
const lateral = perMm * 1e3 * (woods.length === 1 ? 2 : 1);
|
|
25203
|
+
const axial = kind === "screw" ? 234 * (density * d) ** 0.2 * (THREAD_D * d) ** 0.4 * 1e3 : lateral;
|
|
25204
|
+
return { lateral, axial, diameter: d / 1e3, spacing: f.spacing };
|
|
25205
|
+
}
|
|
25206
|
+
function torsionConstant(side, other) {
|
|
25207
|
+
const b = Math.max(side, other);
|
|
25208
|
+
const t = Math.min(side, other);
|
|
25209
|
+
if (b <= 0) return 0;
|
|
25210
|
+
const r = t / b;
|
|
25211
|
+
return b * t ** 3 * (1 / 3 - 0.21 * r * (1 - r ** 4 / 12));
|
|
25212
|
+
}
|
|
25213
|
+
var NO_PLACES = new Int32Array(0);
|
|
25214
|
+
var AXES = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
25215
|
+
function beamOf(part) {
|
|
25216
|
+
const d = part.dims;
|
|
25217
|
+
let a = 0;
|
|
25218
|
+
if (d[1] > d[a]) a = 1;
|
|
25219
|
+
if (d[2] > d[a]) a = 2;
|
|
25220
|
+
const ui = (a + 1) % 3;
|
|
25221
|
+
const vi = (a + 2) % 3;
|
|
25222
|
+
const axis2 = rotateVec(part.rotation, AXES[a]);
|
|
25223
|
+
const u = rotateVec(part.rotation, AXES[ui]);
|
|
25224
|
+
const v = rotateVec(part.rotation, AXES[vi]);
|
|
25225
|
+
const min2 = [Infinity, Infinity, Infinity];
|
|
25226
|
+
const max2 = [-Infinity, -Infinity, -Infinity];
|
|
25227
|
+
for (let i = 0; i < 8; i++) {
|
|
25228
|
+
const c = cornerOf(part, i);
|
|
25229
|
+
for (let k = 0; k < 3; k++) {
|
|
25230
|
+
min2[k] = Math.min(min2[k], c[k]);
|
|
25231
|
+
max2[k] = Math.max(max2[k], c[k]);
|
|
25232
|
+
}
|
|
25233
|
+
}
|
|
25234
|
+
return { part, axis: axis2, u, v, length: d[a], stations: [], nodes: [], min: min2, max: max2 };
|
|
25235
|
+
}
|
|
25236
|
+
function cornerOf(part, i) {
|
|
25237
|
+
const d = part.dims;
|
|
25238
|
+
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]];
|
|
25239
|
+
return vec.add(part.position, rotateVec(part.rotation, local2));
|
|
25240
|
+
}
|
|
25241
|
+
function sectionOf2(beam) {
|
|
25242
|
+
const elastic = beam.part.material.elastic;
|
|
25243
|
+
if (!elastic) return null;
|
|
25244
|
+
const d = beam.part.dims;
|
|
25245
|
+
let a = 0;
|
|
25246
|
+
if (d[1] > d[a]) a = 1;
|
|
25247
|
+
if (d[2] > d[a]) a = 2;
|
|
25248
|
+
const du = d[(a + 1) % 3];
|
|
25249
|
+
const dv = d[(a + 2) % 3];
|
|
25250
|
+
const along3 = beam.part.grain === void 0 || beam.part.grain === a;
|
|
25251
|
+
const e = (along3 ? elastic.alongGPa : elastic.acrossGPa ?? elastic.alongGPa) * 1e9;
|
|
25252
|
+
const g = elastic.shearGPa * 1e9;
|
|
25253
|
+
if (beam.part.round && a === 1) {
|
|
25254
|
+
const r = du / 2;
|
|
25255
|
+
const i = Math.PI * r ** 4 / 4;
|
|
25256
|
+
return { area: Math.PI * r * r, iu: i, iv: i, j: 2 * i, e, g };
|
|
25257
|
+
}
|
|
25258
|
+
return { area: du * dv, iu: du * dv ** 3 / 12, iv: dv * du ** 3 / 12, j: torsionConstant(du, dv), e, g };
|
|
25259
|
+
}
|
|
25260
|
+
function beamLocal(s, length2) {
|
|
25261
|
+
const k = new Float64Array(144);
|
|
25262
|
+
const set2 = (i, j, value) => {
|
|
25263
|
+
k[i * 12 + j] = value;
|
|
25264
|
+
k[j * 12 + i] = value;
|
|
25265
|
+
};
|
|
25266
|
+
const L = length2;
|
|
25267
|
+
const ea = s.e * s.area / L;
|
|
25268
|
+
const gj = s.g * s.j / L;
|
|
25269
|
+
const z = s.e * s.iv;
|
|
25270
|
+
const y = s.e * s.iu;
|
|
25271
|
+
set2(0, 0, ea);
|
|
25272
|
+
set2(0, 6, -ea);
|
|
25273
|
+
set2(6, 6, ea);
|
|
25274
|
+
set2(3, 3, gj);
|
|
25275
|
+
set2(3, 9, -gj);
|
|
25276
|
+
set2(9, 9, gj);
|
|
25277
|
+
set2(1, 1, 12 * z / L ** 3);
|
|
25278
|
+
set2(1, 5, 6 * z / L ** 2);
|
|
25279
|
+
set2(1, 7, -12 * z / L ** 3);
|
|
25280
|
+
set2(1, 11, 6 * z / L ** 2);
|
|
25281
|
+
set2(5, 5, 4 * z / L);
|
|
25282
|
+
set2(5, 7, -6 * z / L ** 2);
|
|
25283
|
+
set2(5, 11, 2 * z / L);
|
|
25284
|
+
set2(7, 7, 12 * z / L ** 3);
|
|
25285
|
+
set2(7, 11, -6 * z / L ** 2);
|
|
25286
|
+
set2(11, 11, 4 * z / L);
|
|
25287
|
+
set2(2, 2, 12 * y / L ** 3);
|
|
25288
|
+
set2(2, 4, -6 * y / L ** 2);
|
|
25289
|
+
set2(2, 8, -12 * y / L ** 3);
|
|
25290
|
+
set2(2, 10, -6 * y / L ** 2);
|
|
25291
|
+
set2(4, 4, 4 * y / L);
|
|
25292
|
+
set2(4, 8, 6 * y / L ** 2);
|
|
25293
|
+
set2(4, 10, 2 * y / L);
|
|
25294
|
+
set2(8, 8, 12 * y / L ** 3);
|
|
25295
|
+
set2(8, 10, 6 * y / L ** 2);
|
|
25296
|
+
set2(10, 10, 4 * y / L);
|
|
25297
|
+
return k;
|
|
25298
|
+
}
|
|
25299
|
+
function toObjectFrame(k, n, x, y, z) {
|
|
25300
|
+
const r = [x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2]];
|
|
25301
|
+
const half = new Float64Array(n * n);
|
|
25302
|
+
const out = new Float64Array(n * n);
|
|
25303
|
+
for (let block = 0; block < n; block += 3) {
|
|
25304
|
+
for (let col = 0; col < n; col++) {
|
|
25305
|
+
for (let i = 0; i < 3; i++) {
|
|
25306
|
+
let sum2 = 0;
|
|
25307
|
+
for (let m = 0; m < 3; m++) sum2 += r[i * 3 + m] * k[(block + m) * n + col];
|
|
25308
|
+
half[(block + i) * n + col] = sum2;
|
|
25309
|
+
}
|
|
25310
|
+
}
|
|
25311
|
+
}
|
|
25312
|
+
for (let row = 0; row < n; row++) {
|
|
25313
|
+
for (let block = 0; block < n; block += 3) {
|
|
25314
|
+
for (let i = 0; i < 3; i++) {
|
|
25315
|
+
let sum2 = 0;
|
|
25316
|
+
for (let m = 0; m < 3; m++) sum2 += half[row * n + block + m] * r[i * 3 + m];
|
|
25317
|
+
out[row * n + block + i] = sum2;
|
|
25318
|
+
}
|
|
25319
|
+
}
|
|
25320
|
+
}
|
|
25321
|
+
return out;
|
|
25322
|
+
}
|
|
25323
|
+
function armRows(arm) {
|
|
25324
|
+
const [x, y, z] = arm;
|
|
25325
|
+
return [
|
|
25326
|
+
[1, 0, 0, 0, z, -y],
|
|
25327
|
+
[0, 1, 0, -z, 0, x],
|
|
25328
|
+
[0, 0, 1, y, -x, 0]
|
|
25329
|
+
];
|
|
25330
|
+
}
|
|
25331
|
+
function stationsOf(joint2, a, b) {
|
|
25332
|
+
const lo = [0, 0, 0];
|
|
25333
|
+
const hi = [0, 0, 0];
|
|
25334
|
+
let touching = true;
|
|
25335
|
+
for (let k = 0; k < 3; k++) {
|
|
25336
|
+
lo[k] = Math.max(a.min[k], b.min[k]);
|
|
25337
|
+
hi[k] = Math.min(a.max[k], b.max[k]);
|
|
25338
|
+
if (hi[k] < lo[k] - TOUCH) touching = false;
|
|
25339
|
+
}
|
|
25340
|
+
const rigid = RIGID_KINDS.has(joint2.kind);
|
|
25341
|
+
const fastener = rigid ? null : fastenerStiffness(joint2.kind, a.part.material, b.part.material);
|
|
25342
|
+
const stiff = rigid || !fastener && JOINT_FASTENERS[joint2.kind] !== void 0;
|
|
25343
|
+
if (!stiff && !fastener) return [];
|
|
25344
|
+
if (!touching) {
|
|
25345
|
+
const frame3 = [[0, 1, 0], [1, 0, 0], [0, 0, 1]];
|
|
25346
|
+
if (stiff || !fastener) return [{ at: joint2.position, frame: frame3, push: [RIGID_PUSH, RIGID_PUSH, RIGID_PUSH], turn: [RIGID_TURN, RIGID_TURN, RIGID_TURN] }];
|
|
25347
|
+
return [{ at: joint2.position, frame: frame3, push: [fastener.axial, fastener.lateral, fastener.lateral], turn: [0, 0, 0] }];
|
|
25348
|
+
}
|
|
25349
|
+
const size = [Math.max(0, hi[0] - lo[0]), Math.max(0, hi[1] - lo[1]), Math.max(0, hi[2] - lo[2])];
|
|
25350
|
+
const middle = [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2];
|
|
25351
|
+
let n = 0;
|
|
25352
|
+
if (size[1] < size[n]) n = 1;
|
|
25353
|
+
if (size[2] < size[n]) n = 2;
|
|
25354
|
+
let w = (n + 1) % 3;
|
|
25355
|
+
let c = (n + 2) % 3;
|
|
25356
|
+
if (size[c] > size[w]) [w, c] = [c, w];
|
|
25357
|
+
const frame2 = [AXES[n], AXES[w], AXES[c]];
|
|
25358
|
+
const along3 = size[w];
|
|
25359
|
+
const across2 = size[c];
|
|
25360
|
+
const d = fastener?.diameter ?? 5e-3;
|
|
25361
|
+
const spacing = fastener?.spacing ?? 0.2;
|
|
25362
|
+
const end3 = END_D * d;
|
|
25363
|
+
const count = along3 > 2 * end3 ? 1 + Math.ceil((along3 - 2 * end3) / spacing) : 1;
|
|
25364
|
+
const stations = Math.min(count, SEAM_STATIONS);
|
|
25365
|
+
const each = count / stations;
|
|
25366
|
+
const out = [];
|
|
25367
|
+
for (let s = 0; s < stations; s++) {
|
|
25368
|
+
const t = stations === 1 ? 0 : -along3 / 2 + end3 + (along3 - 2 * end3) * s / (stations - 1);
|
|
25369
|
+
const at4 = [middle[0], middle[1], middle[2]];
|
|
25370
|
+
at4[w] = middle[w] + t;
|
|
25371
|
+
if (stiff || !fastener) {
|
|
25372
|
+
out.push({ at: at4, frame: frame2, push: [RIGID_PUSH, RIGID_PUSH, RIGID_PUSH], turn: [RIGID_TURN, RIGID_TURN, RIGID_TURN] });
|
|
25373
|
+
continue;
|
|
25374
|
+
}
|
|
25375
|
+
const rows = across2 >= (2 * EDGE_D + ROW_D) * d ? [EDGE_D * d, across2 - EDGE_D * d] : [across2 / 2];
|
|
25376
|
+
const pry = rows.reduce((sum2, r) => sum2 + r * r, 0) * fastener.axial * each;
|
|
25377
|
+
const lone = stations === 1;
|
|
25378
|
+
const pryAlong = lone ? (along3 / 2) ** 2 * fastener.axial * rows.length : 0;
|
|
25379
|
+
const twist = lone && rows.length > 1 ? rows.reduce((sum2, r) => sum2 + (r - across2 / 2) ** 2, 0) * fastener.lateral : 0;
|
|
25380
|
+
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] });
|
|
25381
|
+
}
|
|
25382
|
+
return out;
|
|
25383
|
+
}
|
|
25384
|
+
function sparseOf(count, pairs, last) {
|
|
25385
|
+
const joined = Array.from({ length: count }, () => /* @__PURE__ */ new Set());
|
|
25386
|
+
for (const [a, b] of pairs) {
|
|
25387
|
+
if (a === b) continue;
|
|
25388
|
+
joined[a].add(b);
|
|
25389
|
+
joined[b].add(a);
|
|
25390
|
+
}
|
|
25391
|
+
const order2 = new Int32Array(count).fill(-1);
|
|
25392
|
+
const held = [];
|
|
25393
|
+
for (let rank = 0; rank < count; rank++) {
|
|
25394
|
+
const feet = rank >= count - last.size;
|
|
25395
|
+
let least = -1;
|
|
25396
|
+
for (let i = 0; i < count; i++) if (order2[i] === -1 && last.has(i) === feet && (least === -1 || joined[i].size < joined[least].size)) least = i;
|
|
25397
|
+
order2[least] = rank;
|
|
25398
|
+
const others = [...joined[least]];
|
|
25399
|
+
held.push(others);
|
|
25400
|
+
for (const a of others) {
|
|
25401
|
+
joined[a].delete(least);
|
|
25402
|
+
for (const b of others) if (a !== b) joined[a].add(b);
|
|
25403
|
+
}
|
|
25404
|
+
}
|
|
25405
|
+
const nodeStart = new Int32Array(count + 1);
|
|
25406
|
+
for (let rank = 0; rank < count; rank++) nodeStart[rank + 1] = nodeStart[rank] + held[rank].length;
|
|
25407
|
+
const below = new Int32Array(nodeStart[count]);
|
|
25408
|
+
const beforeStart = new Int32Array(count + 1);
|
|
25409
|
+
for (let rank = 0; rank < count; rank++) {
|
|
25410
|
+
const ranks = held[rank].map((node) => order2[node]).sort((p, q) => p - q);
|
|
25411
|
+
below.set(ranks, nodeStart[rank]);
|
|
25412
|
+
for (const other of ranks) beforeStart[other + 1] = beforeStart[other + 1] + 1;
|
|
25413
|
+
}
|
|
25414
|
+
for (let rank = 0; rank < count; rank++) beforeStart[rank + 1] = beforeStart[rank + 1] + beforeStart[rank];
|
|
25415
|
+
const before = new Int32Array(beforeStart[count]);
|
|
25416
|
+
const filled = beforeStart.slice(0, count);
|
|
25417
|
+
for (let rank = 0; rank < count; rank++) for (let t = nodeStart[rank]; t < nodeStart[rank + 1]; t++) before[filled[below[t]]++] = rank;
|
|
25418
|
+
const n = count * 6;
|
|
25419
|
+
const start = new Int32Array(n + 1);
|
|
25420
|
+
for (let j = 0; j < n; j++) {
|
|
25421
|
+
const rank = Math.floor(j / 6);
|
|
25422
|
+
start[j + 1] = start[j] + (5 - j % 6) + 6 * (nodeStart[rank + 1] - nodeStart[rank]);
|
|
25423
|
+
}
|
|
25424
|
+
const rows = new Int32Array(start[n]);
|
|
25425
|
+
for (let j = 0; j < n; j++) {
|
|
25426
|
+
const rank = Math.floor(j / 6);
|
|
25427
|
+
let p = start[j];
|
|
25428
|
+
for (let i = j + 1; i < rank * 6 + 6; i++) rows[p++] = i;
|
|
25429
|
+
for (let t = nodeStart[rank]; t < nodeStart[rank + 1]; t++) for (let c = 0; c < 6; c++) rows[p++] = below[t] * 6 + c;
|
|
25430
|
+
}
|
|
25431
|
+
const head = (count - last.size) * 6;
|
|
25432
|
+
const tail = start.slice(0, n);
|
|
25433
|
+
for (let j = 0; j < head; j++) while (tail[j] < start[j + 1] && rows[tail[j]] < head) tail[j] = tail[j] + 1;
|
|
25434
|
+
return { order: order2, shape: { n, start, rows, nodeStart, below, beforeStart, before, size: n + rows.length, head, tail } };
|
|
25435
|
+
}
|
|
25436
|
+
function placeOf(shape, i, j) {
|
|
25437
|
+
if (i === j) return i;
|
|
25438
|
+
const rank = Math.floor(j / 6);
|
|
25439
|
+
const other = Math.floor(i / 6);
|
|
25440
|
+
const index = shape.n + shape.start[j];
|
|
25441
|
+
if (other === rank) return index + i - j - 1;
|
|
25442
|
+
let t = shape.nodeStart[rank];
|
|
25443
|
+
const end3 = shape.nodeStart[rank + 1];
|
|
25444
|
+
while (t < end3 && shape.below[t] !== other) t++;
|
|
25445
|
+
if (t === end3) throw new Error(`assemblyFlex: (${i}, ${j}) is of two nodes the matrix was not made with as joined`);
|
|
25446
|
+
return index + 5 - j % 6 + 6 * (t - shape.nodeStart[rank]) + i % 6;
|
|
25447
|
+
}
|
|
25448
|
+
function addAt(shape, k, i, j, value) {
|
|
25449
|
+
if (j > i) return;
|
|
25450
|
+
const index = shape.placeOf(i, j);
|
|
25451
|
+
k[index] = k[index] + value;
|
|
25452
|
+
}
|
|
25453
|
+
function halfQuadratic(shape, k, x) {
|
|
25454
|
+
const { n, start, rows } = shape;
|
|
25455
|
+
let total = 0;
|
|
25456
|
+
for (let j = 0; j < n; j++) {
|
|
25457
|
+
const xj = x[j];
|
|
25458
|
+
if (xj === 0) continue;
|
|
25459
|
+
let column = 0.5 * k[j] * xj;
|
|
25460
|
+
for (let p = start[j]; p < start[j + 1]; p++) column += k[n + p] * x[rows[p]];
|
|
25461
|
+
total += xj * column;
|
|
25462
|
+
}
|
|
25463
|
+
return total;
|
|
25464
|
+
}
|
|
25465
|
+
function factor(shape, k, from, to) {
|
|
25466
|
+
const { n, start, rows, beforeStart, before } = shape;
|
|
25467
|
+
const next = from === 0 ? start.slice(0, n) : shape.tail.slice();
|
|
25468
|
+
const x = new Float64Array(n);
|
|
25469
|
+
const columns = new Int32Array(n);
|
|
25470
|
+
for (let i = from; i < to; i++) {
|
|
25471
|
+
const rank = Math.floor(i / 6);
|
|
25472
|
+
let count = 0;
|
|
25473
|
+
for (let t = beforeStart[rank]; t < beforeStart[rank + 1]; t++) for (let c = 0; c < 6; c++) columns[count++] = before[t] * 6 + c;
|
|
25474
|
+
for (let j = rank * 6; j < i; j++) columns[count++] = j;
|
|
25475
|
+
for (let c = 0; c < count; c++) {
|
|
25476
|
+
const j = columns[c];
|
|
25477
|
+
x[j] = k[n + next[j]];
|
|
25478
|
+
}
|
|
25479
|
+
let diagonal = k[i];
|
|
25480
|
+
for (let c = 0; c < count; c++) {
|
|
25481
|
+
const j = columns[c];
|
|
25482
|
+
const value = x[j] / k[j];
|
|
25483
|
+
x[j] = 0;
|
|
25484
|
+
const end3 = next[j];
|
|
25485
|
+
for (let p = start[j]; p < end3; p++) x[rows[p]] = x[rows[p]] - k[n + p] * value;
|
|
25486
|
+
diagonal -= value * value;
|
|
25487
|
+
k[n + end3] = value;
|
|
25488
|
+
next[j] = end3 + 1;
|
|
25489
|
+
}
|
|
25490
|
+
if (!(diagonal > 0)) return false;
|
|
25491
|
+
k[i] = Math.sqrt(diagonal);
|
|
25492
|
+
}
|
|
25493
|
+
return true;
|
|
25494
|
+
}
|
|
25495
|
+
function substitute(shape, k, f) {
|
|
25496
|
+
const { n, start, rows } = shape;
|
|
25497
|
+
for (let j = 0; j < n; j++) {
|
|
25498
|
+
const value = f[j] / k[j];
|
|
25499
|
+
f[j] = value;
|
|
25500
|
+
for (let p = start[j]; p < start[j + 1]; p++) f[rows[p]] = f[rows[p]] - k[n + p] * value;
|
|
25501
|
+
}
|
|
25502
|
+
for (let j = n - 1; j >= 0; j--) {
|
|
25503
|
+
let sum2 = f[j];
|
|
25504
|
+
for (let p = start[j]; p < start[j + 1]; p++) sum2 -= k[n + p] * f[rows[p]];
|
|
25505
|
+
f[j] = sum2 / k[j];
|
|
25506
|
+
}
|
|
25507
|
+
}
|
|
25508
|
+
var sparseLinear = (count, pairs, last) => {
|
|
25509
|
+
const { order: order2, shape } = sparseOf(count, pairs, last);
|
|
25510
|
+
return {
|
|
25511
|
+
order: order2,
|
|
25512
|
+
size: shape.size,
|
|
25513
|
+
head: shape.head,
|
|
25514
|
+
placeOf: (i, j) => placeOf(shape, i, j),
|
|
25515
|
+
factor: (k, from, to) => factor(shape, k, from, to),
|
|
25516
|
+
substitute: (k, f) => substitute(shape, k, f),
|
|
25517
|
+
halfQuadratic: (k, x) => halfQuadratic(shape, k, x)
|
|
25518
|
+
};
|
|
25519
|
+
};
|
|
25520
|
+
function hullOf(points) {
|
|
25521
|
+
const sorted = [...points].sort((p, q) => p[0] - q[0] || p[1] - q[1]);
|
|
25522
|
+
const turn2 = (o, p, q) => (p[0] - o[0]) * (q[1] - o[1]) - (p[1] - o[1]) * (q[0] - o[0]);
|
|
25523
|
+
const lower = [];
|
|
25524
|
+
for (const p of sorted) {
|
|
25525
|
+
while (lower.length >= 2 && turn2(lower[lower.length - 2], lower[lower.length - 1], p) <= 1e-12) lower.pop();
|
|
25526
|
+
lower.push([p[0], p[1]]);
|
|
25527
|
+
}
|
|
25528
|
+
const upper = [];
|
|
25529
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
25530
|
+
const p = sorted[i];
|
|
25531
|
+
while (upper.length >= 2 && turn2(upper[upper.length - 2], upper[upper.length - 1], p) <= 1e-12) upper.pop();
|
|
25532
|
+
upper.push([p[0], p[1]]);
|
|
25533
|
+
}
|
|
25534
|
+
lower.pop();
|
|
25535
|
+
upper.pop();
|
|
25536
|
+
return [...lower, ...upper];
|
|
25537
|
+
}
|
|
25538
|
+
function assemblyFlex(input) {
|
|
25539
|
+
const g = input.gravity ?? GRAVITY2;
|
|
25540
|
+
const lost = new Set(input.lost ?? []);
|
|
25541
|
+
const beams = /* @__PURE__ */ new Map();
|
|
25542
|
+
for (const part of input.parts) {
|
|
25543
|
+
if (part.mass <= 0 || Math.max(...part.dims) <= 0) continue;
|
|
25544
|
+
beams.set(part.id, beamOf(part));
|
|
25545
|
+
}
|
|
25546
|
+
if (beams.size === 0) return null;
|
|
25547
|
+
const floor2 = input.floor ?? Math.min(...[...beams.values()].map((b) => b.min[1]));
|
|
25548
|
+
const joints = input.joints.filter((j) => beams.has(j.a) && beams.has(j.b) && j.a !== j.b);
|
|
25549
|
+
const structural = (j) => RIGID_KINDS.has(j.kind) || JOINT_FASTENERS[j.kind] !== void 0;
|
|
25550
|
+
const stationed = /* @__PURE__ */ new Map();
|
|
25551
|
+
const along3 = (beam, p) => Math.max(-beam.length / 2, Math.min(beam.length / 2, vec.dot(vec.sub(p, beam.part.position), beam.axis)));
|
|
25552
|
+
for (const beam of beams.values()) beam.stations.push(-beam.length / 2, beam.length / 2);
|
|
25553
|
+
for (const joint2 of joints) {
|
|
25554
|
+
if (!structural(joint2)) continue;
|
|
25555
|
+
const a = beams.get(joint2.a);
|
|
25556
|
+
const b = beams.get(joint2.b);
|
|
25557
|
+
const stations = stationsOf(joint2, a, b);
|
|
25558
|
+
stationed.set(joint2, stations);
|
|
25559
|
+
for (const s of stations) {
|
|
25560
|
+
a.stations.push(along3(a, s.at));
|
|
25561
|
+
b.stations.push(along3(b, s.at));
|
|
25562
|
+
}
|
|
25563
|
+
}
|
|
25564
|
+
const footPoints = /* @__PURE__ */ new Map();
|
|
25565
|
+
for (const beam of beams.values()) {
|
|
25566
|
+
if (beam.min[1] > floor2 + FOOT_BAND) continue;
|
|
25567
|
+
const corners = [];
|
|
25568
|
+
for (let i = 0; i < 8; i++) {
|
|
25569
|
+
const c = cornerOf(beam.part, i);
|
|
25570
|
+
if (c[1] <= beam.min[1] + 5e-3) corners.push(c);
|
|
25571
|
+
}
|
|
25572
|
+
footPoints.set(beam.part.id, corners);
|
|
25573
|
+
for (const c of corners) beam.stations.push(along3(beam, c));
|
|
25574
|
+
}
|
|
25575
|
+
const nodes = [];
|
|
25576
|
+
for (const beam of beams.values()) {
|
|
25577
|
+
const sides = beam.part.dims.filter((d) => d !== beam.length);
|
|
25578
|
+
const merge = Math.max(2e-3, 0.5 * Math.min(...sides, beam.length));
|
|
25579
|
+
const sorted = [...beam.stations].sort((p, q) => p - q);
|
|
25580
|
+
const met = [];
|
|
25581
|
+
for (const s of sorted) if (met.length === 0 || s - met[met.length - 1] > merge) met.push(s);
|
|
25582
|
+
if (met.length > 1 && beam.length / 2 - met[met.length - 1] > 0) met[met.length - 1] = beam.length / 2;
|
|
25583
|
+
const longest = beam.length >= SLENDER * Math.max(...sides, 0) && Math.abs(beam.axis[1]) < UPRIGHT ? beam.length / BEAM_PIECES : Infinity;
|
|
25584
|
+
const kept = [];
|
|
25585
|
+
for (const [i, s] of met.entries()) {
|
|
25586
|
+
const from = met[i - 1];
|
|
25587
|
+
if (from !== void 0 && s - from > longest * 1.01) {
|
|
25588
|
+
const cuts = Math.ceil((s - from) / longest);
|
|
25589
|
+
for (let c = 1; c < cuts; c++) kept.push(from + (s - from) * c / cuts);
|
|
25590
|
+
}
|
|
25591
|
+
kept.push(s);
|
|
25592
|
+
}
|
|
25593
|
+
beam.stations = kept;
|
|
25594
|
+
beam.nodes = kept.map((s) => nodes.push({ at: vec.madd(beam.part.position, beam.axis, s) }) - 1);
|
|
25595
|
+
}
|
|
25596
|
+
if (nodes.length * 6 > MAX_DOF) return null;
|
|
25597
|
+
const order2 = new Int32Array(nodes.length);
|
|
25598
|
+
for (let i = 0; i < nodes.length; i++) order2[i] = i;
|
|
25599
|
+
const dofsOf = (node) => [0, 1, 2, 3, 4, 5].map((i) => order2[node] * 6 + i);
|
|
25600
|
+
const nearest = (beam, p) => {
|
|
25601
|
+
const t = along3(beam, p);
|
|
25602
|
+
let best = 0;
|
|
25603
|
+
for (let i = 1; i < beam.stations.length; i++) if (Math.abs(beam.stations[i] - t) < Math.abs(beam.stations[best] - t)) best = i;
|
|
25604
|
+
return beam.nodes[best];
|
|
25605
|
+
};
|
|
25606
|
+
const made = [];
|
|
25607
|
+
for (const beam of beams.values()) {
|
|
25608
|
+
const section = sectionOf2(beam);
|
|
25609
|
+
if (!section) {
|
|
25610
|
+
const id = beam.part.id;
|
|
25611
|
+
if (footPoints.has(id) || joints.some((j) => structural(j) && (j.a === id || j.b === id))) return null;
|
|
25612
|
+
continue;
|
|
25613
|
+
}
|
|
25614
|
+
for (let i = 0; i + 1 < beam.nodes.length; i++) {
|
|
25615
|
+
const length2 = beam.stations[i + 1] - beam.stations[i];
|
|
25616
|
+
const k = toObjectFrame(beamLocal(section, length2), 12, beam.axis, beam.u, beam.v);
|
|
25617
|
+
made.push({ dofs: [...dofsOf(beam.nodes[i]), ...dofsOf(beam.nodes[i + 1])], k, parts: [beam.part.id], places: NO_PLACES });
|
|
25618
|
+
}
|
|
25619
|
+
}
|
|
25620
|
+
for (const [joint2, stations] of stationed) {
|
|
25621
|
+
const a = beams.get(joint2.a);
|
|
25622
|
+
const b = beams.get(joint2.b);
|
|
25623
|
+
for (const s of stations) {
|
|
25624
|
+
const na = nearest(a, s.at);
|
|
25625
|
+
const nb = nearest(b, s.at);
|
|
25626
|
+
const ra = armRows(vec.sub(s.at, nodes[na].at));
|
|
25627
|
+
const rb = armRows(vec.sub(s.at, nodes[nb].at));
|
|
25628
|
+
const rows = [];
|
|
25629
|
+
for (let i = 0; i < 3; i++) rows.push([...ra[i].map((x) => -x), ...rb[i]]);
|
|
25630
|
+
for (let i = 0; i < 3; i++) {
|
|
25631
|
+
const row = new Array(12).fill(0);
|
|
25632
|
+
row[3 + i] = -1;
|
|
25633
|
+
row[9 + i] = 1;
|
|
25634
|
+
rows.push(row);
|
|
25635
|
+
}
|
|
25636
|
+
const k = new Float64Array(144);
|
|
25637
|
+
for (let axis2 = 0; axis2 < 3; axis2++) {
|
|
25638
|
+
const e = s.frame[axis2];
|
|
25639
|
+
for (const [stiffness, base2] of [[s.push[axis2], 0], [s.turn[axis2], 3]]) {
|
|
25640
|
+
if (stiffness === 0) continue;
|
|
25641
|
+
const b12 = new Array(12).fill(0);
|
|
25642
|
+
for (let i = 0; i < 3; i++) for (let m = 0; m < 12; m++) b12[m] = b12[m] + e[i] * rows[base2 + i][m];
|
|
25643
|
+
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];
|
|
25644
|
+
}
|
|
25645
|
+
}
|
|
25646
|
+
made.push({ dofs: [...dofsOf(na), ...dofsOf(nb)], k, parts: [joint2.a, joint2.b], places: NO_PLACES });
|
|
25647
|
+
}
|
|
25648
|
+
}
|
|
25649
|
+
const supports = [];
|
|
25650
|
+
for (const [id, corners] of footPoints) {
|
|
25651
|
+
const beam = beams.get(id);
|
|
25652
|
+
for (const at4 of corners) {
|
|
25653
|
+
const node = nearest(beam, at4);
|
|
25654
|
+
supports.push({ part: id, node, arm: vec.sub(at4, nodes[node].at), at: at4 });
|
|
25655
|
+
}
|
|
25656
|
+
}
|
|
25657
|
+
const shape = (input.linear ?? sparseLinear)(nodes.length, made.map((element) => [Math.floor(element.dofs[0] / 6), Math.floor(element.dofs[6] / 6)]), new Set(supports.map((s) => s.node)));
|
|
25658
|
+
order2.set(shape.order);
|
|
25659
|
+
const elements = made.map((element) => {
|
|
25660
|
+
const dofs = element.dofs.map((dof) => order2[Math.floor(dof / 6)] * 6 + dof % 6);
|
|
25661
|
+
const places = new Int32Array(dofs.length * dofs.length);
|
|
25662
|
+
for (let p = 0; p < dofs.length; p++) for (let q = 0; q < dofs.length; q++) places[p * dofs.length + q] = dofs[q] > dofs[p] ? -1 : shape.placeOf(dofs[p], dofs[q]);
|
|
25663
|
+
return { ...element, dofs, places };
|
|
25664
|
+
});
|
|
25665
|
+
const frame2 = { nodes, beams, elements, supports, order: order2, shape };
|
|
25666
|
+
const before = lost.size > 0 ? solveFrame(frame2, input, joints, structural, /* @__PURE__ */ new Set(), g, null) : null;
|
|
25667
|
+
const after2 = solveFrame(frame2, input, joints, structural, lost, g, before);
|
|
25668
|
+
if (!after2) return null;
|
|
25669
|
+
let mass = 0;
|
|
25670
|
+
const centre = [0, 0, 0];
|
|
25671
|
+
const shift = [0, 0, 0];
|
|
25672
|
+
let all = 0;
|
|
25673
|
+
const allCentre = [0, 0, 0];
|
|
25674
|
+
const moved = (s, point) => {
|
|
25675
|
+
const base2 = order2[point.node] * 6;
|
|
25676
|
+
const theta = [s.u[base2 + 3], s.u[base2 + 4], s.u[base2 + 5]];
|
|
25677
|
+
return vec.add([s.u[base2], s.u[base2 + 1], s.u[base2 + 2]], vec.cross(theta, point.arm));
|
|
25678
|
+
};
|
|
25679
|
+
for (const p of after2.masses) {
|
|
25680
|
+
const at4 = vec.add(nodes[p.node].at, p.arm);
|
|
25681
|
+
const by = moved(after2, p);
|
|
25682
|
+
all += p.mass;
|
|
25683
|
+
for (let k = 0; k < 3; k++) allCentre[k] = allCentre[k] + (at4[k] + by[k]) * p.mass;
|
|
25684
|
+
if (p.part === null) continue;
|
|
25685
|
+
mass += p.mass;
|
|
25686
|
+
for (let k = 0; k < 3; k++) {
|
|
25687
|
+
centre[k] = centre[k] + at4[k] * p.mass;
|
|
25688
|
+
shift[k] = shift[k] + by[k] * p.mass;
|
|
25689
|
+
}
|
|
25690
|
+
}
|
|
25691
|
+
if (mass <= 0) return null;
|
|
25692
|
+
for (let k = 0; k < 3; k++) {
|
|
25693
|
+
centre[k] = centre[k] / mass;
|
|
25694
|
+
shift[k] = shift[k] / mass;
|
|
25695
|
+
allCentre[k] = allCentre[k] / all;
|
|
25696
|
+
}
|
|
25697
|
+
const feet = after2.holding.map((s) => s.at);
|
|
25698
|
+
let released = 0;
|
|
25699
|
+
let spin = null;
|
|
25700
|
+
if (before) {
|
|
25701
|
+
const n = nodes.length * 6;
|
|
25702
|
+
const delta = new Float64Array(n);
|
|
25703
|
+
for (let i = 0; i < n; i++) delta[i] = after2.u[i] - before.u[i];
|
|
25704
|
+
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;
|
|
25705
|
+
released = frame2.shape.halfQuadratic(after2.k, delta);
|
|
25706
|
+
spin = spinOf({ frame: frame2, after: after2, delta, released, centre: allCentre, mass: all, floor: floor2, g });
|
|
25707
|
+
}
|
|
25708
|
+
return {
|
|
25709
|
+
mass,
|
|
25710
|
+
centre,
|
|
25711
|
+
shift,
|
|
25712
|
+
released,
|
|
25713
|
+
spin,
|
|
25714
|
+
feet,
|
|
25715
|
+
deflection(id, point) {
|
|
25716
|
+
const beam = beams.get(id);
|
|
25717
|
+
if (!beam || !after2.standing.has(id)) return null;
|
|
25718
|
+
const node = nearest(beam, point);
|
|
25719
|
+
return moved(after2, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 });
|
|
25720
|
+
},
|
|
25721
|
+
settlement(id) {
|
|
25722
|
+
const beam = beams.get(id);
|
|
25723
|
+
if (!beam) return null;
|
|
25724
|
+
const carrier = after2.standing.has(id) ? null : after2.masses.find((p) => p.part === id);
|
|
25725
|
+
if (!after2.standing.has(id) && !carrier) return null;
|
|
25726
|
+
const from = vec.madd(beam.part.position, beam.axis, -beam.length / 2);
|
|
25727
|
+
const to = vec.madd(beam.part.position, beam.axis, beam.length / 2);
|
|
25728
|
+
const drop = [];
|
|
25729
|
+
for (let i = 0; i < SAG_STATIONS; i++) {
|
|
25730
|
+
const point = vec.madd(from, beam.axis, beam.length * i / (SAG_STATIONS - 1));
|
|
25731
|
+
const node = carrier ? carrier.node : nearest(beam, point);
|
|
25732
|
+
drop.push(-moved(after2, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 })[1]);
|
|
25733
|
+
}
|
|
25734
|
+
return { from, to, drop };
|
|
25735
|
+
}
|
|
25736
|
+
};
|
|
25737
|
+
}
|
|
25738
|
+
function standingParts(frame2, joints, structural, gone) {
|
|
25739
|
+
const standing = /* @__PURE__ */ new Set();
|
|
25740
|
+
const queue = [];
|
|
25741
|
+
for (const s of frame2.supports) {
|
|
25742
|
+
if (gone.has(s.part) || standing.has(s.part)) continue;
|
|
25743
|
+
standing.add(s.part);
|
|
25744
|
+
queue.push(s.part);
|
|
25745
|
+
}
|
|
25746
|
+
while (queue.length > 0) {
|
|
25747
|
+
const id = queue.pop();
|
|
25748
|
+
for (const j of joints) {
|
|
25749
|
+
if (!structural(j) || j.a !== id && j.b !== id) continue;
|
|
25750
|
+
const other = j.a === id ? j.b : j.a;
|
|
25751
|
+
if (gone.has(other) || standing.has(other)) continue;
|
|
25752
|
+
standing.add(other);
|
|
25753
|
+
queue.push(other);
|
|
25754
|
+
}
|
|
25755
|
+
}
|
|
25756
|
+
return standing;
|
|
25757
|
+
}
|
|
25758
|
+
function solveFrame(frame2, input, joints, structural, gone, g, from) {
|
|
25759
|
+
const { nodes, beams, order: order2, shape } = frame2;
|
|
25760
|
+
const n = nodes.length * 6;
|
|
25761
|
+
const standing = standingParts(frame2, joints, structural, gone);
|
|
25762
|
+
if (standing.size === 0) return null;
|
|
25763
|
+
const nearestNode = (p, among) => {
|
|
25764
|
+
let best = -1;
|
|
25765
|
+
let bestDistance = Infinity;
|
|
25766
|
+
for (const id of among) {
|
|
25767
|
+
const beam = beams.get(id);
|
|
25768
|
+
for (const node of beam.nodes) {
|
|
25769
|
+
const d = vec.distance(nodes[node].at, p);
|
|
25770
|
+
if (d < bestDistance) {
|
|
25771
|
+
bestDistance = d;
|
|
25772
|
+
best = node;
|
|
25773
|
+
}
|
|
25774
|
+
}
|
|
25775
|
+
}
|
|
25776
|
+
return best;
|
|
25777
|
+
};
|
|
25778
|
+
const masses = [];
|
|
25779
|
+
for (const id of standing) {
|
|
25780
|
+
const beam = beams.get(id);
|
|
25781
|
+
const perMetre = beam.part.mass / beam.length;
|
|
25782
|
+
for (let i = 0; i < beam.nodes.length; i++) {
|
|
25783
|
+
const before = i > 0 ? beam.stations[i] - beam.stations[i - 1] : 0;
|
|
25784
|
+
const next = i + 1 < beam.nodes.length ? beam.stations[i + 1] - beam.stations[i] : 0;
|
|
25785
|
+
masses.push({ part: id, node: beam.nodes[i], arm: [0, 0, 0], mass: perMetre * (before + next) / 2 });
|
|
25786
|
+
}
|
|
25787
|
+
}
|
|
25788
|
+
const carried = /* @__PURE__ */ new Map();
|
|
25789
|
+
let grew = true;
|
|
25790
|
+
while (grew) {
|
|
25791
|
+
grew = false;
|
|
25792
|
+
for (const j of joints) {
|
|
25793
|
+
for (const [id, host] of [[j.a, j.b], [j.b, j.a]]) {
|
|
25794
|
+
if (gone.has(id) || gone.has(host) || standing.has(id) || carried.has(id)) continue;
|
|
25795
|
+
if (!standing.has(host) && !carried.has(host)) continue;
|
|
25796
|
+
carried.set(id, standing.has(host) ? host : carried.get(host));
|
|
25797
|
+
grew = true;
|
|
25798
|
+
}
|
|
25799
|
+
}
|
|
25800
|
+
}
|
|
25801
|
+
for (const [id, host] of carried) {
|
|
25802
|
+
const part = beams.get(id).part;
|
|
25803
|
+
const node = nearestNode(part.position, [host]);
|
|
25804
|
+
masses.push({ part: id, node, arm: vec.sub(part.position, nodes[node].at), mass: part.mass });
|
|
25805
|
+
}
|
|
25806
|
+
for (const load of input.loads ?? []) {
|
|
25807
|
+
if (load.mass <= 0) continue;
|
|
25808
|
+
const node = nearestNode(load.position, standing);
|
|
25809
|
+
masses.push({ part: null, node, arm: vec.sub(load.position, nodes[node].at), mass: load.mass });
|
|
25810
|
+
}
|
|
25811
|
+
const f = new Float64Array(n);
|
|
25812
|
+
for (const p of masses) {
|
|
25813
|
+
const base2 = order2[p.node] * 6;
|
|
25814
|
+
const weight = -p.mass * g;
|
|
25815
|
+
f[base2 + 1] = f[base2 + 1] + weight;
|
|
25816
|
+
f[base2 + 3] = f[base2 + 3] - p.arm[2] * weight;
|
|
25817
|
+
f[base2 + 5] = f[base2 + 5] + p.arm[0] * weight;
|
|
25818
|
+
}
|
|
25819
|
+
const structure = new Float64Array(shape.size);
|
|
25820
|
+
let largest = 0;
|
|
25821
|
+
for (const element of frame2.elements) {
|
|
25822
|
+
if (!element.parts.every((id) => standing.has(id))) continue;
|
|
25823
|
+
const { places, k: k2 } = element;
|
|
25824
|
+
for (let t = 0; t < places.length; t++) if (places[t] >= 0) structure[places[t]] = structure[places[t]] + k2[t];
|
|
25825
|
+
}
|
|
25826
|
+
for (let i = 0; i < n; i++) largest = Math.max(largest, structure[i]);
|
|
25827
|
+
if (largest <= 0) return null;
|
|
25828
|
+
const free = new Uint8Array(n);
|
|
25829
|
+
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;
|
|
25830
|
+
for (let i = 0; i < n; i++) {
|
|
25831
|
+
if (!free[i]) {
|
|
25832
|
+
structure[i] = largest;
|
|
25833
|
+
f[i] = 0;
|
|
25834
|
+
} else addAt(shape, structure, i, i, largest * SOFT);
|
|
25835
|
+
}
|
|
25836
|
+
const feet = frame2.supports.filter((s) => standing.has(s.part));
|
|
25837
|
+
const holds3 = feet.map((s) => !from || from.holding.includes(s));
|
|
25838
|
+
const footed = [...new Set(feet.map((s) => s.part))];
|
|
25839
|
+
const grips = new Map(footed.map((id) => [id, true]));
|
|
25840
|
+
const friction = input.friction ?? FOOT_FRICTION;
|
|
25841
|
+
const factored = structure.slice();
|
|
25842
|
+
if (!shape.factor(factored, 0, shape.head)) return null;
|
|
25843
|
+
const k = new Float64Array(shape.size);
|
|
25844
|
+
const u = new Float64Array(n);
|
|
25845
|
+
const build = (from2) => {
|
|
25846
|
+
k.set(from2);
|
|
25847
|
+
const held = /* @__PURE__ */ new Map();
|
|
25848
|
+
feet.forEach((s, index) => {
|
|
25849
|
+
if (!holds3[index]) return;
|
|
25850
|
+
const row = armRows(s.arm)[1];
|
|
25851
|
+
const base2 = order2[s.node] * 6;
|
|
25852
|
+
for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++) addAt(shape, k, base2 + p, base2 + q, RIGID_PUSH * row[p] * row[q]);
|
|
25853
|
+
held.set(s.part, [...held.get(s.part) ?? [], s]);
|
|
25854
|
+
});
|
|
25855
|
+
for (const [id, points] of held) {
|
|
25856
|
+
const { node, arm } = gripOf(points);
|
|
25857
|
+
const upright = order2[node] * 6 + 4;
|
|
25858
|
+
addAt(shape, k, upright, upright, RIGID_TURN);
|
|
25859
|
+
if (!grips.get(id)) continue;
|
|
25860
|
+
const rows = armRows(arm);
|
|
25861
|
+
const base2 = order2[node] * 6;
|
|
25862
|
+
for (const row of [rows[0], rows[2]]) for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++) addAt(shape, k, base2 + p, base2 + q, RIGID_PUSH * row[p] * row[q]);
|
|
25863
|
+
}
|
|
25864
|
+
};
|
|
25865
|
+
const liftOf = (s) => {
|
|
25866
|
+
const base2 = order2[s.node] * 6;
|
|
25867
|
+
return u[base2 + 1] + (u[base2 + 5] * s.arm[0] - u[base2 + 3] * s.arm[2]);
|
|
25868
|
+
};
|
|
25869
|
+
const rounds = 4 * feet.length + 2 * footed.length + 4;
|
|
25870
|
+
for (let round5 = 0; round5 < rounds; round5++) {
|
|
25871
|
+
build(factored);
|
|
25872
|
+
u.set(f);
|
|
25873
|
+
if (!shape.factor(k, shape.head, n)) return null;
|
|
25874
|
+
shape.substitute(k, u);
|
|
25875
|
+
const pull = 1e-12;
|
|
25876
|
+
const sink = -1e-9;
|
|
25877
|
+
if (round5 === 0) {
|
|
25878
|
+
let any = false;
|
|
25879
|
+
feet.forEach((s, index) => {
|
|
25880
|
+
if (!holds3[index] || liftOf(s) <= pull) return;
|
|
25881
|
+
holds3[index] = false;
|
|
25882
|
+
any = true;
|
|
25883
|
+
});
|
|
25884
|
+
if (any) continue;
|
|
25885
|
+
}
|
|
25886
|
+
const worstOf = /* @__PURE__ */ new Map();
|
|
25887
|
+
feet.forEach((s, index) => {
|
|
25888
|
+
const lift = liftOf(s);
|
|
25889
|
+
const pulls = holds3[index] && lift > pull;
|
|
25890
|
+
if (!pulls && !(!holds3[index] && lift < sink)) return;
|
|
25891
|
+
const key2 = round5 < rounds / 2 ? s.part : "";
|
|
25892
|
+
const by = Math.abs(lift);
|
|
25893
|
+
const now = worstOf.get(key2);
|
|
25894
|
+
if (!now || pulls && !now.pulls || pulls === now.pulls && by > now.by) worstOf.set(key2, { index, by, pulls });
|
|
25895
|
+
});
|
|
25896
|
+
if (worstOf.size > 0) {
|
|
25897
|
+
for (const change of worstOf.values()) holds3[change.index] = !change.pulls;
|
|
25898
|
+
continue;
|
|
25899
|
+
}
|
|
25900
|
+
let slides = null;
|
|
25901
|
+
let over = 1;
|
|
25902
|
+
let gripping = 0;
|
|
25903
|
+
for (const id of footed) {
|
|
25904
|
+
const points = feet.filter((s, index) => s.part === id && holds3[index]);
|
|
25905
|
+
if (points.length === 0 || !grips.get(id)) continue;
|
|
25906
|
+
gripping++;
|
|
25907
|
+
let weight = 0;
|
|
25908
|
+
for (const s of points) weight += -RIGID_PUSH * liftOf(s);
|
|
25909
|
+
const { node, arm } = gripOf(points);
|
|
25910
|
+
const base2 = order2[node] * 6;
|
|
25911
|
+
const x = u[base2] + (u[base2 + 4] * arm[2] - u[base2 + 5] * arm[1]);
|
|
25912
|
+
const z = u[base2 + 2] + (u[base2 + 3] * arm[1] - u[base2 + 4] * arm[0]);
|
|
25913
|
+
const ratio = RIGID_PUSH * Math.hypot(x, z) / Math.max(friction * weight, 1e-9);
|
|
25914
|
+
if (ratio > over) {
|
|
25915
|
+
over = ratio;
|
|
25916
|
+
slides = id;
|
|
25917
|
+
}
|
|
25918
|
+
}
|
|
25919
|
+
if (slides !== null && gripping > 1) {
|
|
25920
|
+
grips.set(slides, false);
|
|
25921
|
+
continue;
|
|
25922
|
+
}
|
|
25923
|
+
let worst = 0;
|
|
25924
|
+
for (let i = 0; i < n; i++) if (free[i]) worst = Math.max(worst, Math.abs(u[i]));
|
|
25925
|
+
if (worst > MECHANISM) return null;
|
|
25926
|
+
const holding = feet.filter((_, index) => holds3[index]);
|
|
25927
|
+
if (holding.length < 3) return null;
|
|
25928
|
+
build(structure);
|
|
25929
|
+
return { u: u.slice(), k: k.slice(), holding, masses, standing };
|
|
25930
|
+
}
|
|
25931
|
+
return null;
|
|
25932
|
+
}
|
|
25933
|
+
function gripOf(points) {
|
|
25934
|
+
const first = points[0];
|
|
25935
|
+
let arm = [0, 0, 0];
|
|
25936
|
+
for (const s of points) arm = vec.add(arm, vec.sub(s.at, vec.sub(first.at, first.arm)));
|
|
25937
|
+
return { node: first.node, arm: vec.scale(arm, 1 / points.length) };
|
|
25938
|
+
}
|
|
25939
|
+
function spinOf(input) {
|
|
25940
|
+
const { frame: frame2, after: after2, delta, released, centre, mass, floor: floor2, g } = input;
|
|
25941
|
+
if (!(released > 0)) return null;
|
|
25942
|
+
const { nodes, order: order2 } = frame2;
|
|
25943
|
+
const points = after2.masses.map((p) => {
|
|
25944
|
+
const base2 = order2[p.node] * 6;
|
|
25945
|
+
const theta = [delta[base2 + 3], delta[base2 + 4], delta[base2 + 5]];
|
|
25946
|
+
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 };
|
|
25947
|
+
});
|
|
25948
|
+
let moving = 0;
|
|
25949
|
+
for (const p of points) moving += p.mass * vec.dot(p.by, p.by);
|
|
25950
|
+
if (!(moving > 0)) return null;
|
|
25951
|
+
const scale = Math.sqrt(2 * released / moving);
|
|
25952
|
+
const hull = hullOf(after2.holding.map((s) => [s.at[0], s.at[2]]));
|
|
25953
|
+
if (hull.length < 3) return null;
|
|
25954
|
+
let best = null;
|
|
25955
|
+
for (let i = 0; i < hull.length; i++) {
|
|
25956
|
+
const p = hull[i];
|
|
25957
|
+
const q = hull[(i + 1) % hull.length];
|
|
25958
|
+
const length2 = Math.hypot(q[0] - p[0], q[1] - p[1]);
|
|
25959
|
+
if (length2 < 1e-9) continue;
|
|
25960
|
+
const point = [p[0], floor2, p[1]];
|
|
25961
|
+
let axis2 = [(q[0] - p[0]) / length2, 0, (q[1] - p[1]) / length2];
|
|
25962
|
+
const inward = [centre[0] - point[0], 0, centre[2] - point[2]];
|
|
25963
|
+
let out = vec.cross(axis2, [0, 1, 0]);
|
|
25964
|
+
if (vec.dot(out, inward) > 0) {
|
|
25965
|
+
axis2 = vec.scale(axis2, -1);
|
|
25966
|
+
out = vec.scale(out, -1);
|
|
25967
|
+
}
|
|
25968
|
+
const depth = -vec.dot(out, inward);
|
|
25969
|
+
let momentum = 0;
|
|
25970
|
+
let inertia = 0;
|
|
25971
|
+
for (const m of points) {
|
|
25972
|
+
const r = vec.sub(m.at, point);
|
|
25973
|
+
const off = vec.sub(r, vec.scale(axis2, vec.dot(r, axis2)));
|
|
25974
|
+
momentum += m.mass * vec.dot(vec.cross(r, vec.scale(m.by, scale)), axis2);
|
|
25975
|
+
inertia += m.mass * vec.dot(off, off);
|
|
25976
|
+
}
|
|
25977
|
+
if (!(inertia > 0)) continue;
|
|
25978
|
+
const rate = momentum / inertia;
|
|
25979
|
+
if (!(rate > 0)) continue;
|
|
25980
|
+
const height = centre[1] - floor2;
|
|
25981
|
+
const barrier = depth > 0 ? mass * g * (Math.hypot(height, depth) - height) : 0;
|
|
25982
|
+
const energy = 0.5 * inertia * rate * rate;
|
|
25983
|
+
const margin = energy - barrier;
|
|
25984
|
+
if (!best || margin > best.margin) best = { point, axis: axis2, rate, margin, energy, barrier };
|
|
25985
|
+
}
|
|
25986
|
+
return best ? { point: best.point, axis: best.axis, rate: best.rate, energy: best.energy, barrier: best.barrier } : null;
|
|
25987
|
+
}
|
|
25022
25988
|
var SWEEP_BROAD_SLACK = 1e-3;
|
|
25023
25989
|
var sweptBounds = (origins, direction, length2) => {
|
|
25024
25990
|
if (origins.length === 0 || !Number.isFinite(length2)) return null;
|
|
@@ -25208,6 +26174,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25208
26174
|
var MAX_PLASTER_FLAKES = 24;
|
|
25209
26175
|
var CHIP_ENERGY = 200;
|
|
25210
26176
|
var CHIP_SPLASH = 0.5;
|
|
26177
|
+
var SHARD_CUT = [0.3, 0.7];
|
|
25211
26178
|
var MORTAR_JOINT = 0.01;
|
|
25212
26179
|
var MIN_UNIT_SHARE = 0.8;
|
|
25213
26180
|
var CHIP_DRIVE = 0.6;
|
|
@@ -25247,16 +26214,38 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25247
26214
|
};
|
|
25248
26215
|
var BURIED_BLAST_REACH = 0.5;
|
|
25249
26216
|
var GIVE_AT_CUT_HP = 0.5;
|
|
26217
|
+
var lineToSegment = (o, d, a, b) => {
|
|
26218
|
+
const ab = vec.sub(b, a);
|
|
26219
|
+
const ao = vec.sub(a, o);
|
|
26220
|
+
const abab = vec.dot(ab, ab);
|
|
26221
|
+
const abd = vec.dot(ab, d);
|
|
26222
|
+
const denom = abab - abd * abd;
|
|
26223
|
+
if (abab < 1e-12) return null;
|
|
26224
|
+
if (denom < 1e-12) {
|
|
26225
|
+
const end3 = vec.dot(ao, d) <= vec.dot(vec.sub(b, o), d) ? a : b;
|
|
26226
|
+
return { point: end3, distance: vec.distance(end3, vec.madd(o, d, vec.dot(vec.sub(end3, o), d))) };
|
|
26227
|
+
}
|
|
26228
|
+
const s = clamp2((abd * vec.dot(ao, d) - vec.dot(ao, ab)) / denom, 0, 1);
|
|
26229
|
+
const point = vec.madd(a, ab, s);
|
|
26230
|
+
const t = vec.dot(vec.sub(point, o), d);
|
|
26231
|
+
return { point, distance: vec.distance(point, vec.madd(o, d, t)) };
|
|
26232
|
+
};
|
|
26233
|
+
var cageLeft = (p) => {
|
|
26234
|
+
const r = p.spec.reinforcement;
|
|
26235
|
+
if (!r) return 1;
|
|
26236
|
+
const total = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length;
|
|
26237
|
+
return total > 0 ? Math.max(0, total - (p.rt.severedBars?.length ?? 0)) / total : 1;
|
|
26238
|
+
};
|
|
25250
26239
|
var capacityScale = (p, borne, through) => {
|
|
25251
26240
|
const residual = p.spec.reinforcement?.residualCapacity ?? RESIDUAL_CAPACITY;
|
|
25252
|
-
if (p.st.stripped) return residual;
|
|
26241
|
+
if (p.st.stripped) return residual * cageLeft(p);
|
|
25253
26242
|
const kept = Math.min(p.rt.removed ? 1 - p.rt.removed / p.mass0 : 1, sectionKept(p, residual, borne, through));
|
|
25254
26243
|
return Math.max(p.spec.reinforcement ? residual : 0.05, kept);
|
|
25255
26244
|
};
|
|
25256
26245
|
var sectionKept = (p, residual, borne, through) => {
|
|
25257
26246
|
let kept = 1;
|
|
25258
|
-
forEachSection(p, borne, (c,
|
|
25259
|
-
const share = through?.(c.center,
|
|
26247
|
+
forEachSection(p, borne, (c, along3, gone) => {
|
|
26248
|
+
const share = through?.(c.center, along3) ?? 1;
|
|
25260
26249
|
if (share <= 0) return;
|
|
25261
26250
|
kept = Math.min(kept, Math.max(p.spec.reinforcement ? residual : 0, 1 - gone) / share);
|
|
25262
26251
|
});
|
|
@@ -25281,12 +26270,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25281
26270
|
const last = cells[cells.length - 1];
|
|
25282
26271
|
if (!known || known.spec !== p.spec || known.count !== cells.length || known.last !== last) {
|
|
25283
26272
|
const places = [];
|
|
25284
|
-
let
|
|
26273
|
+
let along3 = 0;
|
|
25285
26274
|
measureSections(p, cells, void 0, (c, a, gone) => {
|
|
25286
|
-
|
|
26275
|
+
along3 = a;
|
|
25287
26276
|
places.push({ c, gone });
|
|
25288
26277
|
});
|
|
25289
|
-
known = { spec: p.spec, count: cells.length, last, along:
|
|
26278
|
+
known = { spec: p.spec, count: cells.length, last, along: along3, lying: sectionLying(p, along3), places };
|
|
25290
26279
|
sectionsByCells.set(cells, known);
|
|
25291
26280
|
}
|
|
25292
26281
|
for (const { c, gone } of known.places) {
|
|
@@ -25294,24 +26283,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25294
26283
|
visit(c, known.along, gone);
|
|
25295
26284
|
}
|
|
25296
26285
|
};
|
|
25297
|
-
var sectionLying = (p,
|
|
26286
|
+
var sectionLying = (p, along3) => {
|
|
25298
26287
|
const [u, v] = planeAxes(p.thin);
|
|
25299
26288
|
const up = rotateVec(p.q, [0, 0, 0].map((_, k) => k === v ? 1 : 0));
|
|
25300
26289
|
const upright = Math.abs(up[1]) > 0.7 ? v : Math.abs(rotateVec(p.q, [0, 0, 0].map((_, k) => k === u ? 1 : 0))[1]) > 0.7 ? u : -1;
|
|
25301
|
-
return
|
|
26290
|
+
return along3 !== upright || upright < 0;
|
|
25302
26291
|
};
|
|
25303
26292
|
var measureSections = (p, cells, borne, visit) => {
|
|
25304
26293
|
const [u, v] = planeAxes(p.thin);
|
|
25305
26294
|
const role = p.spec.structure?.role;
|
|
25306
26295
|
const up = rotateVec(p.q, [0, 0, 0].map((_, k) => k === v ? 1 : 0));
|
|
25307
26296
|
const upright = Math.abs(up[1]) > 0.7 ? v : Math.abs(rotateVec(p.q, [0, 0, 0].map((_, k) => k === u ? 1 : 0))[1]) > 0.7 ? u : -1;
|
|
25308
|
-
const
|
|
25309
|
-
const across2 =
|
|
25310
|
-
const lying =
|
|
26297
|
+
const along3 = (role === "wall" || role === "partition" || role === "column") && upright >= 0 ? upright : p.dims[u] >= p.dims[v] ? u : v;
|
|
26298
|
+
const across2 = along3 === u ? v : u;
|
|
26299
|
+
const lying = along3 !== upright || upright < 0;
|
|
25311
26300
|
for (const c of cells) {
|
|
25312
|
-
if (lying && borne?.(c.center,
|
|
26301
|
+
if (lying && borne?.(c.center, along3)) continue;
|
|
25313
26302
|
const spans = [];
|
|
25314
|
-
for (const d of cells) if (Math.abs(d.center[
|
|
26303
|
+
for (const d of cells) if (Math.abs(d.center[along3] - c.center[along3]) < d.size[along3] / 2 + 1e-6) spans.push([d.center[across2] - d.size[across2] / 2, d.center[across2] + d.size[across2] / 2]);
|
|
25315
26304
|
spans.sort((a, b) => a[0] - b[0]);
|
|
25316
26305
|
let gone = 0, end3 = -Infinity;
|
|
25317
26306
|
for (const [a, b] of spans) {
|
|
@@ -25319,11 +26308,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25319
26308
|
gone += b - Math.max(a, end3);
|
|
25320
26309
|
end3 = b;
|
|
25321
26310
|
}
|
|
25322
|
-
visit(c,
|
|
26311
|
+
visit(c, along3, Math.min(1, gone / Math.max(p.dims[across2], 1e-6)));
|
|
25323
26312
|
}
|
|
25324
26313
|
};
|
|
25325
26314
|
var HOSTED_TOLERANCE = 0.02;
|
|
25326
26315
|
var HOLE_SLACK = 0.05;
|
|
26316
|
+
var GRAIN_AXIS = { x: 0, y: 1, z: 2 };
|
|
25327
26317
|
var isLost = (p) => p.st.status === "broken" || p.st.status === "melted" || p.st.status === "ashes";
|
|
25328
26318
|
var clone = (v) => structuredClone(v);
|
|
25329
26319
|
var overloadRate = (stress) => Math.min(0.6, 0.12 + 0.8 * (stress - 1));
|
|
@@ -25390,6 +26380,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25390
26380
|
const primed = /* @__PURE__ */ new Map();
|
|
25391
26381
|
let orderCounter = 0;
|
|
25392
26382
|
const impls = /* @__PURE__ */ new Map();
|
|
26383
|
+
let implsRevision = 0;
|
|
25393
26384
|
const taken = (id) => objects.has(id) || impls.has(id);
|
|
25394
26385
|
const emit2 = (e) => {
|
|
25395
26386
|
cur.push(e);
|
|
@@ -25777,13 +26768,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25777
26768
|
if (load <= 0) return void 0;
|
|
25778
26769
|
const above2 = Math.max(0, load - p.st.mass);
|
|
25779
26770
|
const up = rotateVec(p.q, [0, 1, 0]);
|
|
25780
|
-
return (local2,
|
|
26771
|
+
return (local2, along3) => {
|
|
25781
26772
|
const axis2 = [0, 0, 0];
|
|
25782
|
-
axis2[
|
|
26773
|
+
axis2[along3] = 1;
|
|
25783
26774
|
const sign2 = Math.sign(rotateVec(p.q, axis2)[1]);
|
|
25784
26775
|
if (Math.abs(up[1]) < 0.7 && Math.abs(rotateVec(p.q, axis2)[1]) < 0.7) return 1;
|
|
25785
|
-
const half = p.dims[
|
|
25786
|
-
const share = clamp2((half - sign2 * local2[
|
|
26776
|
+
const half = p.dims[along3] / 2;
|
|
26777
|
+
const share = clamp2((half - sign2 * local2[along3]) / Math.max(p.dims[along3], 1e-6), 0, 1);
|
|
25787
26778
|
return (above2 + p.st.mass * share) / load;
|
|
25788
26779
|
};
|
|
25789
26780
|
};
|
|
@@ -25845,7 +26836,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25845
26836
|
const borneOn = (p, supports) => {
|
|
25846
26837
|
if (supports.length === 0) return void 0;
|
|
25847
26838
|
const boxes = supports.map((support) => contactBox(p, support));
|
|
25848
|
-
return (local2,
|
|
26839
|
+
return (local2, along3) => boxes.some(([lo, hi]) => local2[along3] >= lo[along3] - SUPPORT_TOLERANCE && local2[along3] <= hi[along3] + SUPPORT_TOLERANCE);
|
|
25849
26840
|
};
|
|
25850
26841
|
const measureContact = (p, support) => {
|
|
25851
26842
|
const A = aabbOf(p.spec.shape, p.pos, p.q), B = aabbOf(support.spec.shape, support.pos, support.q);
|
|
@@ -25898,7 +26889,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25898
26889
|
byKey.set(key2, span);
|
|
25899
26890
|
return span;
|
|
25900
26891
|
};
|
|
25901
|
-
const
|
|
26892
|
+
const sectionOf22 = (p, axis2) => {
|
|
25902
26893
|
const g = p.bend;
|
|
25903
26894
|
const section = { b: sectionWidth(g, axis2), h: g.dims[axis2] };
|
|
25904
26895
|
const rebar2 = tensionSteel(p.spec, g.dims, section, flexure);
|
|
@@ -25913,7 +26904,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25913
26904
|
}
|
|
25914
26905
|
p.restMoment = 0;
|
|
25915
26906
|
if (g.gravity < 0 || p.span <= 0) return 0;
|
|
25916
|
-
const sec =
|
|
26907
|
+
const sec = sectionOf22(p, g.gravity);
|
|
25917
26908
|
p.restMoment = spanMoment(lineLoad(g, p.bendLoad) * Math.abs(g.up[g.gravity]), p.span);
|
|
25918
26909
|
const holds3 = (p.st.cracked ? sec.steel : sec.ultimate) * capacityScale(p);
|
|
25919
26910
|
return p.restMoment * structureSafety / Math.max(holds3, 1);
|
|
@@ -25948,16 +26939,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25948
26939
|
const impulse = sum2 / offsets.length * cos2 * reach2 * width * L;
|
|
25949
26940
|
const weight = axis2 === g.gravity ? p.bendLoad : p.st.mass;
|
|
25950
26941
|
const kinetic = impulseEnergy(impulse, lineLoad(g, weight) / GRAVITY * L, flexure);
|
|
25951
|
-
const sec =
|
|
26942
|
+
const sec = sectionOf22(p, axis2);
|
|
25952
26943
|
const EI = s.elasticGPa * 1e9 * sec.section.b * sec.section.h ** 3 / 12;
|
|
25953
|
-
const
|
|
26944
|
+
const along3 = axis2 === g.gravity ? -Math.sign(away[axis2] * g.up[axis2]) : 0;
|
|
25954
26945
|
const dynamic2 = momentOfEnergy(kinetic, L, EI, flexure.loadFactor);
|
|
25955
|
-
const peak = Math.abs(dynamic2 +
|
|
26946
|
+
const peak = Math.abs(dynamic2 + along3 * p.restMoment);
|
|
25956
26947
|
if (peak <= sec.cracking) return;
|
|
25957
26948
|
if (!p.st.cracked) {
|
|
25958
26949
|
p.st.cracked = true;
|
|
25959
26950
|
const tension = [near.point[0], near.point[1], near.point[2]];
|
|
25960
|
-
tension[axis2] = dynamic2 +
|
|
26951
|
+
tension[axis2] = dynamic2 + along3 * p.restMoment >= 0 ? -face : face;
|
|
25961
26952
|
const n = [0, 0, 0];
|
|
25962
26953
|
n[axis2] = Math.sign(tension[axis2]) || 1;
|
|
25963
26954
|
addCrack(o, p, toWorld(c, q, tension), rotateVec(q, n), sec.section.b, src);
|
|
@@ -26092,7 +27083,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26092
27083
|
p.bendLoad = p.st.mass + bending[i];
|
|
26093
27084
|
const bent = restFlexure(o, p, lowerOf(i));
|
|
26094
27085
|
p.st.flexure = bent;
|
|
26095
|
-
p.snap = bent > 1 && !p.st.stripped && !
|
|
27086
|
+
p.snap = bent > 1 && !p.st.stripped && !sectionOf22(p, p.bend.gravity).reinforced;
|
|
26096
27087
|
if (p.spec.structure?.capacity === void 0 || bent > p.st.stress) p.st.stress = bent;
|
|
26097
27088
|
}
|
|
26098
27089
|
if (p.st.stress > o.maxStress) o.maxStress = p.st.stress;
|
|
@@ -26129,7 +27120,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26129
27120
|
if (!terrain) throw new Error(`unknown wind terrain "${cfg.terrain}"`);
|
|
26130
27121
|
const inputs = [];
|
|
26131
27122
|
const at4 = /* @__PURE__ */ new Map();
|
|
26132
|
-
const
|
|
27123
|
+
const keep2 = [];
|
|
26133
27124
|
let ground = Infinity, foundationTop = -Infinity;
|
|
26134
27125
|
o.parts.forEach((p, i) => {
|
|
26135
27126
|
if (isLost(p) || isTerrain(p) || o.collapsed.has(p.spec.id) || o.unsup[i]) return;
|
|
@@ -26138,12 +27129,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26138
27129
|
const e = p.mat.strength?.elasticGPa;
|
|
26139
27130
|
const kind = role === "wall" ? "wall" : role === "column" ? "column" : role === "beam" ? "beam" : role === "foundation" ? "foundation" : "other";
|
|
26140
27131
|
at4.set(i, inputs.length);
|
|
26141
|
-
|
|
27132
|
+
keep2.push(i);
|
|
26142
27133
|
ground = Math.min(ground, box5.min[1]);
|
|
26143
27134
|
if (kind === "foundation") foundationTop = Math.max(foundationTop, box5.max[1]);
|
|
26144
27135
|
inputs.push({ min: box5.min, max: box5.max, kind, ...e ? { elasticPa: e * 1e9 } : {}, mass: p.st.mass, ...p.spec.damper ? { damper: true } : {} });
|
|
26145
27136
|
});
|
|
26146
|
-
|
|
27137
|
+
keep2.forEach((i, k) => {
|
|
26147
27138
|
if (inputs[k].kind !== "column") return;
|
|
26148
27139
|
const beams = [];
|
|
26149
27140
|
for (const j of o.byPart.get(o.parts[i].spec.id)) {
|
|
@@ -26153,7 +27144,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26153
27144
|
}
|
|
26154
27145
|
inputs[k].beams = beams;
|
|
26155
27146
|
});
|
|
26156
|
-
|
|
27147
|
+
keep2.forEach((i, k) => {
|
|
26157
27148
|
if (inputs[k].kind !== "beam") return;
|
|
26158
27149
|
for (const j of o.byPart.get(o.parts[i].spec.id)) {
|
|
26159
27150
|
if (j.st.open) continue;
|
|
@@ -26187,14 +27178,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26187
27178
|
};
|
|
26188
27179
|
const a = inputs.length && cfg.speed > 0 ? analyzeWind(inputs, c, foundationTop > -Infinity ? foundationTop : ground) : null;
|
|
26189
27180
|
w.analysis = a;
|
|
26190
|
-
w.parts =
|
|
27181
|
+
w.parts = keep2;
|
|
26191
27182
|
for (const p of o.parts) delete p.st.wind;
|
|
26192
27183
|
if (!a) {
|
|
26193
27184
|
w.sys = null;
|
|
26194
27185
|
delete o.st.wind;
|
|
26195
27186
|
return;
|
|
26196
27187
|
}
|
|
26197
|
-
|
|
27188
|
+
keep2.forEach((i, k) => {
|
|
26198
27189
|
const N = a.axial[k];
|
|
26199
27190
|
const p = o.parts[i];
|
|
26200
27191
|
if (!N || !p.structural || o.unsup[i]) return;
|
|
@@ -26228,7 +27219,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26228
27219
|
w.gust = makeGust(v10, cfg.gust);
|
|
26229
27220
|
}
|
|
26230
27221
|
let md = 0, spec;
|
|
26231
|
-
for (const i of
|
|
27222
|
+
for (const i of keep2) {
|
|
26232
27223
|
const p = o.parts[i];
|
|
26233
27224
|
if (!p.spec.damper) continue;
|
|
26234
27225
|
const phi = shapeAt(a, p.pos[1] - (foundationTop > -Infinity ? foundationTop : ground));
|
|
@@ -26372,10 +27363,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26372
27363
|
iz += sp.k * (sp.z - z0) ** 2;
|
|
26373
27364
|
}
|
|
26374
27365
|
const { c } = soilWeight(o);
|
|
26375
|
-
const
|
|
26376
|
-
const off =
|
|
27366
|
+
const along3 = ix <= iz ? 0 : 1;
|
|
27367
|
+
const off = along3 === 0 ? c[0] - x0 : c[2] - z0;
|
|
26377
27368
|
const sign2 = Math.abs(off) > 1e-6 ? Math.sign(off) : 1;
|
|
26378
|
-
so.imp =
|
|
27369
|
+
so.imp = along3 === 0 ? [sign2 * soilCfg.imperfection, 0] : [0, sign2 * soilCfg.imperfection];
|
|
26379
27370
|
if (carried) {
|
|
26380
27371
|
const t = Math.tan(carried.tilt * Math.PI / 180);
|
|
26381
27372
|
so.s = carried.settlement;
|
|
@@ -26623,10 +27614,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26623
27614
|
const cut = undercutAt(loss, Math.hypot(world2[0] - loss.x, world2[2] - loss.z), b.embed, groundCfg.spread);
|
|
26624
27615
|
if (cut >= groundCfg.voidDepth) {
|
|
26625
27616
|
open++;
|
|
26626
|
-
const
|
|
27617
|
+
const along3 = local2[long] - box5.min[long];
|
|
26627
27618
|
const side = local2[across2] - box5.min[across2];
|
|
26628
|
-
voidBox ?? (voidBox = { long: [
|
|
26629
|
-
voidBox.long = [Math.min(voidBox.long[0],
|
|
27619
|
+
voidBox ?? (voidBox = { long: [along3, along3], across: [side, side] });
|
|
27620
|
+
voidBox.long = [Math.min(voidBox.long[0], along3 - step / 2), Math.max(voidBox.long[1], along3 + step / 2)];
|
|
26630
27621
|
voidBox.across = [Math.min(voidBox.across[0], side), Math.max(voidBox.across[1], side)];
|
|
26631
27622
|
}
|
|
26632
27623
|
drop += Math.min(cut, groundCfg.maxSettlement);
|
|
@@ -26730,9 +27721,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26730
27721
|
if (j.st.open || restsOn(o, j, k) !== b.i) continue;
|
|
26731
27722
|
const q = o.parts[k];
|
|
26732
27723
|
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
26733
|
-
const
|
|
27724
|
+
const along3 = (c.min[fp.long] + c.max[fp.long]) / 2 - box5.min[fp.long];
|
|
26734
27725
|
const side = (c.min[across2] + c.max[across2]) / 2 - box5.min[across2];
|
|
26735
|
-
if (
|
|
27726
|
+
if (along3 >= vb.long[0] && along3 <= vb.long[1] && side >= vb.across[0] && side <= vb.across[1]) out.push({ q, j });
|
|
26736
27727
|
}
|
|
26737
27728
|
return out;
|
|
26738
27729
|
};
|
|
@@ -26950,7 +27941,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26950
27941
|
const units = q.spec.units?.size;
|
|
26951
27942
|
const step = units ? [Math.max(units[0], units[2]), units[1]] : [BRICK_STEP[0], BRICK_STEP[1]];
|
|
26952
27943
|
const reach2 = Math.hypot(toward2[0], toward2[2]) || 1;
|
|
26953
|
-
const
|
|
27944
|
+
const along3 = vec.normalize([toward2[0] / reach2, 1, toward2[2] / reach2]);
|
|
26954
27945
|
const width = clamp2(beta * SETTLEMENT_CRACK_OPENING, MIN_CRACK_WIDTH, MAX_CRACK_WIDTH);
|
|
26955
27946
|
const through = q.dims[q.thin];
|
|
26956
27947
|
for (let c = 0; c < count; c++) {
|
|
@@ -26958,7 +27949,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26958
27949
|
const local2 = [clamp2(at4[0] - toward2[0] / reach2 * back2, box5.min[0], box5.max[0]), box5.min[1] + height * (0.2 + 0.12 * c), clamp2(at4[2] - toward2[2] / reach2 * back2, box5.min[2], box5.max[2])];
|
|
26959
27950
|
const face = toLocal(q.pos, q.q, local2);
|
|
26960
27951
|
face[q.thin] = through / 2;
|
|
26961
|
-
addCrack(o, q, toWorld(o.st.position, o.st.rotation, toWorld(q.pos, q.q, face)), normal, length2, src, { along:
|
|
27952
|
+
addCrack(o, q, toWorld(o.st.position, o.st.rotation, toWorld(q.pos, q.q, face)), normal, length2, src, { along: along3, step, width, through });
|
|
26962
27953
|
}
|
|
26963
27954
|
if (beta >= damageAt && prior < damageAt) {
|
|
26964
27955
|
q.st.hp = Math.max(1, q.st.hp - q.st.maxHp * groundCfg.distortionDamage);
|
|
@@ -27123,11 +28114,79 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27123
28114
|
return r ? { t0: r.t0, t1: r.t1, n: rotateVec(q, r.n0) } : null;
|
|
27124
28115
|
};
|
|
27125
28116
|
const rayPart = (o, p, origin, d) => rayPartRaw(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
|
|
28117
|
+
const rayCentre = [0, 0, 0];
|
|
28118
|
+
const rayTurn = [0, 0, 0, 1];
|
|
28119
|
+
const rayTurnBack = [0, 0, 0, 1];
|
|
28120
|
+
const rayOrigin = [0, 0, 0];
|
|
28121
|
+
const rayDirection = [0, 0, 0];
|
|
28122
|
+
const rayShapeHit = { t0: 0, t1: 0, n0: [0, 0, 0] };
|
|
28123
|
+
const rayHitNormal = [0, 0, 0];
|
|
28124
|
+
const rayHit = { t0: 0, t1: 0, n: rayHitNormal };
|
|
28125
|
+
const rayPartInto = (pos, rot, spec, pq, origin, d, lp) => {
|
|
28126
|
+
rotateVecInto(rot, lp, rayCentre);
|
|
28127
|
+
rayCentre[0] += pos[0];
|
|
28128
|
+
rayCentre[1] += pos[1];
|
|
28129
|
+
rayCentre[2] += pos[2];
|
|
28130
|
+
rayTurn[0] = rot[3] * pq[0] + rot[0] * pq[3] + rot[1] * pq[2] - rot[2] * pq[1];
|
|
28131
|
+
rayTurn[1] = rot[3] * pq[1] - rot[0] * pq[2] + rot[1] * pq[3] + rot[2] * pq[0];
|
|
28132
|
+
rayTurn[2] = rot[3] * pq[2] + rot[0] * pq[1] - rot[1] * pq[0] + rot[2] * pq[3];
|
|
28133
|
+
rayTurn[3] = rot[3] * pq[3] - rot[0] * pq[0] - rot[1] * pq[1] - rot[2] * pq[2];
|
|
28134
|
+
rayTurnBack[0] = -rayTurn[0];
|
|
28135
|
+
rayTurnBack[1] = -rayTurn[1];
|
|
28136
|
+
rayTurnBack[2] = -rayTurn[2];
|
|
28137
|
+
rayTurnBack[3] = rayTurn[3];
|
|
28138
|
+
rayOrigin[0] = origin[0] - rayCentre[0];
|
|
28139
|
+
rayOrigin[1] = origin[1] - rayCentre[1];
|
|
28140
|
+
rayOrigin[2] = origin[2] - rayCentre[2];
|
|
28141
|
+
rotateVecInto(rayTurnBack, rayOrigin, rayOrigin);
|
|
28142
|
+
rotateVecInto(rayTurnBack, d, rayDirection);
|
|
28143
|
+
if (!rayShapeInto(spec.shape, rayOrigin, rayDirection, rayShapeHit)) return null;
|
|
28144
|
+
rayHit.t0 = rayShapeHit.t0;
|
|
28145
|
+
rayHit.t1 = rayShapeHit.t1;
|
|
28146
|
+
rayHit.n = rotateVecInto(rayTurn, rayShapeHit.n0, rayHitNormal);
|
|
28147
|
+
return rayHit;
|
|
28148
|
+
};
|
|
28149
|
+
const specTurns = /* @__PURE__ */ new WeakMap();
|
|
28150
|
+
const specTurnOf = (ps) => {
|
|
28151
|
+
let turn2 = specTurns.get(ps);
|
|
28152
|
+
if (!turn2) {
|
|
28153
|
+
turn2 = quatFromEuler2(...ps.rotation ?? [0, 0, 0]);
|
|
28154
|
+
specTurns.set(ps, turn2);
|
|
28155
|
+
}
|
|
28156
|
+
return turn2;
|
|
28157
|
+
};
|
|
28158
|
+
const copyOf2 = (v) => [v[0], v[1], v[2]];
|
|
28159
|
+
let bestInto = null;
|
|
28160
|
+
const rayPoint = [0, 0, 0];
|
|
28161
|
+
const keepBest = (into, object2, part, point, normal, distance4, pathLen) => {
|
|
28162
|
+
if (!into) return { object: object2, part, point: copyOf2(point), normal: copyOf2(normal), distance: distance4, pathLen };
|
|
28163
|
+
into.object = object2;
|
|
28164
|
+
into.part = part;
|
|
28165
|
+
into.point[0] = point[0];
|
|
28166
|
+
into.point[1] = point[1];
|
|
28167
|
+
into.point[2] = point[2];
|
|
28168
|
+
into.normal[0] = normal[0];
|
|
28169
|
+
into.normal[1] = normal[1];
|
|
28170
|
+
into.normal[2] = normal[2];
|
|
28171
|
+
into.distance = distance4;
|
|
28172
|
+
into.pathLen = pathLen;
|
|
28173
|
+
return into;
|
|
28174
|
+
};
|
|
28175
|
+
const bestScratch = { object: "", part: "", point: [0, 0, 0], normal: [0, 0, 0], distance: 0, pathLen: 0 };
|
|
28176
|
+
const isTerrainPart = (objectId, partId) => {
|
|
28177
|
+
const parts2 = objects.get(objectId)?.parts;
|
|
28178
|
+
if (!parts2) return false;
|
|
28179
|
+
for (const p of parts2) if (p.spec.id === partId) return p.spec.tags?.includes("terrain") === true;
|
|
28180
|
+
return false;
|
|
28181
|
+
};
|
|
28182
|
+
const objectTurnBack = [0, 0, 0, 1];
|
|
28183
|
+
const objectOrigin = [0, 0, 0];
|
|
28184
|
+
const objectDirection = [0, 0, 0];
|
|
27126
28185
|
const PART_BOUND_SLACK = 1e-6;
|
|
27127
28186
|
const raySphereMiss = (origin, d, c, r, maxDist) => {
|
|
27128
|
-
const
|
|
27129
|
-
const b =
|
|
27130
|
-
const cc =
|
|
28187
|
+
const ox = origin[0] - c[0], oy = origin[1] - c[1], oz = origin[2] - c[2];
|
|
28188
|
+
const b = ox * d[0] + oy * d[1] + oz * d[2];
|
|
28189
|
+
const cc = ox * ox + oy * oy + oz * oz - r * r;
|
|
27131
28190
|
if (cc > 0 && b > 0) return true;
|
|
27132
28191
|
const disc = b * b - cc;
|
|
27133
28192
|
if (disc < 0) return true;
|
|
@@ -27243,21 +28302,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27243
28302
|
if (o.parts.length < PART_GRID_MIN_PARTS || !lo.every(Number.isFinite) || !ld.every(Number.isFinite)) return o.parts;
|
|
27244
28303
|
partGridOf(o).candidates(lo, ld, maxDist, gridCandidates);
|
|
27245
28304
|
gridParts.length = 0;
|
|
27246
|
-
for (
|
|
28305
|
+
for (let i = 0; i < gridCandidates.length; i++) gridParts.push(o.parts[gridCandidates[i]]);
|
|
27247
28306
|
return gridParts;
|
|
27248
28307
|
};
|
|
27249
28308
|
const splitInto = (o, cuts) => {
|
|
27250
|
-
const carryFor = (
|
|
27251
|
-
parts: new Map(o.parts.filter((p) =>
|
|
28309
|
+
const carryFor = (keep2, keepOpen = () => false) => ({
|
|
28310
|
+
parts: new Map(o.parts.filter((p) => keep2(p.spec.id)).map((p) => [p.spec.id, { st: p.st, rt: p.rt }])),
|
|
27252
28311
|
joints: new Map([
|
|
27253
|
-
...o.joints.filter((j) =>
|
|
28312
|
+
...o.joints.filter((j) => keep2(j.spec.a) && keep2(j.spec.b) || j.st.open && keepOpen(j.spec.a, j.spec.b)).map((j) => [j.spec.id, { st: j.st, step: j.step }]),
|
|
27254
28313
|
...o.st.joints.filter((st) => st.open && !o.jointMap.has(st.id) && keepOpen(st.a, st.b)).map((st) => [st.id, { st, step: 0 }])
|
|
27255
28314
|
]),
|
|
27256
|
-
collapsed: [...o.collapsed].filter(
|
|
28315
|
+
collapsed: [...o.collapsed].filter(keep2),
|
|
27257
28316
|
cast: o.cast
|
|
27258
28317
|
});
|
|
27259
|
-
const sub2 = (
|
|
27260
|
-
const s = { ...o.spec, parts: o.spec.parts.filter((p) =>
|
|
28318
|
+
const sub2 = (keep2) => {
|
|
28319
|
+
const s = { ...o.spec, parts: o.spec.parts.filter((p) => keep2(p.id)), joints: (o.spec.joints ?? []).filter((j) => keep2(j.a) && keep2(j.b)) };
|
|
27261
28320
|
if (o.spec.tags) s.tags = [...o.spec.tags];
|
|
27262
28321
|
return s;
|
|
27263
28322
|
};
|
|
@@ -27282,6 +28341,28 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27282
28341
|
let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
|
|
27283
28342
|
const metObjects = [];
|
|
27284
28343
|
const rayObjects = [];
|
|
28344
|
+
let objectList = [];
|
|
28345
|
+
let objectListFor = -1;
|
|
28346
|
+
const objectsInOrder = () => {
|
|
28347
|
+
if (objectListFor !== objectsRevision) {
|
|
28348
|
+
objectList = [...objects.values()];
|
|
28349
|
+
objectListFor = objectsRevision;
|
|
28350
|
+
}
|
|
28351
|
+
return objectList;
|
|
28352
|
+
};
|
|
28353
|
+
let implList = [];
|
|
28354
|
+
let implListFor = -1;
|
|
28355
|
+
const implsInOrder = () => {
|
|
28356
|
+
if (implListFor !== implsRevision) {
|
|
28357
|
+
implList = [...impls.values()];
|
|
28358
|
+
implListFor = implsRevision;
|
|
28359
|
+
}
|
|
28360
|
+
return implList;
|
|
28361
|
+
};
|
|
28362
|
+
const NO_IMPLS = [];
|
|
28363
|
+
const NO_SKIP = {};
|
|
28364
|
+
const rayDirections = [];
|
|
28365
|
+
let rayDepth = 0;
|
|
27285
28366
|
const candidatesOf2 = (hook) => {
|
|
27286
28367
|
const asked = hook.candidates;
|
|
27287
28368
|
if (!asked) return null;
|
|
@@ -27307,23 +28388,54 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27307
28388
|
}
|
|
27308
28389
|
return rayObjects;
|
|
27309
28390
|
};
|
|
27310
|
-
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip =
|
|
27311
|
-
const
|
|
28391
|
+
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = NO_SKIP, scope2, drawn = false, passed) => {
|
|
28392
|
+
const into = bestInto;
|
|
28393
|
+
bestInto = null;
|
|
28394
|
+
const d = rayDirections[rayDepth] ?? (rayDirections[rayDepth] = [0, 0, 0]);
|
|
28395
|
+
const length2 = Math.sqrt(dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2]);
|
|
28396
|
+
if (length2 < 1e-9) {
|
|
28397
|
+
d[0] = 0;
|
|
28398
|
+
d[1] = 1;
|
|
28399
|
+
d[2] = 0;
|
|
28400
|
+
} else {
|
|
28401
|
+
d[0] = dir[0] / length2;
|
|
28402
|
+
d[1] = dir[1] / length2;
|
|
28403
|
+
d[2] = dir[2] / length2;
|
|
28404
|
+
}
|
|
28405
|
+
rayDepth++;
|
|
28406
|
+
try {
|
|
28407
|
+
return rayFrom(origin, d, maxDist, into, ignore, worldOnly, precise, skip, scope2, drawn, passed);
|
|
28408
|
+
} finally {
|
|
28409
|
+
rayDepth--;
|
|
28410
|
+
}
|
|
28411
|
+
};
|
|
28412
|
+
const rayFrom = (origin, d, maxDist, into, ignore, worldOnly, precise, skip, scope2, drawn, passed) => {
|
|
27312
28413
|
const asked = rayBroad && !scope2 && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
|
|
27313
28414
|
const candidates = asked ? candidatesOf2(asked) : null;
|
|
27314
28415
|
const outside = candidates ? null : asked;
|
|
27315
28416
|
const minRadius = skip.minObjectRadius ?? 0;
|
|
27316
28417
|
let best = null;
|
|
27317
28418
|
const counts = sweepCounts;
|
|
27318
|
-
|
|
28419
|
+
const visited = scope2 ? scope2.objects : candidates ?? objectsInOrder();
|
|
28420
|
+
for (let oi = 0; oi < visited.length; oi++) {
|
|
28421
|
+
const o = visited[oi];
|
|
27319
28422
|
if (counts) counts.objectVisits++;
|
|
27320
28423
|
if (skip.skipLoose && o.loose || o.br < minRadius) continue;
|
|
27321
28424
|
if (outside && !outside.mayMeet(o.id)) continue;
|
|
27322
28425
|
if (raySphereMiss(origin, d, worldCentreOf(o), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
|
|
27323
|
-
const
|
|
27324
|
-
|
|
27325
|
-
|
|
27326
|
-
|
|
28426
|
+
const turn2 = o.st.rotation;
|
|
28427
|
+
objectTurnBack[0] = -turn2[0];
|
|
28428
|
+
objectTurnBack[1] = -turn2[1];
|
|
28429
|
+
objectTurnBack[2] = -turn2[2];
|
|
28430
|
+
objectTurnBack[3] = turn2[3];
|
|
28431
|
+
objectOrigin[0] = origin[0] - o.st.position[0];
|
|
28432
|
+
objectOrigin[1] = origin[1] - o.st.position[1];
|
|
28433
|
+
objectOrigin[2] = origin[2] - o.st.position[2];
|
|
28434
|
+
const lo = rotateVecInto(objectTurnBack, objectOrigin, objectOrigin);
|
|
28435
|
+
const ld = rotateVecInto(objectTurnBack, d, objectDirection);
|
|
28436
|
+
const along3 = scope2?.parts.get(o) ?? (counts ? o.parts : partsAlong(o, lo, ld, maxDist));
|
|
28437
|
+
for (let pi = 0; pi < along3.length; pi++) {
|
|
28438
|
+
const p = along3[pi];
|
|
27327
28439
|
if (counts) counts.partVisits++;
|
|
27328
28440
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
27329
28441
|
if (partSphereMiss(lo, ld, p, maxDist)) continue;
|
|
@@ -27331,15 +28443,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27331
28443
|
counts.shapeTests++;
|
|
27332
28444
|
counts.shapeTested.add(o.id);
|
|
27333
28445
|
}
|
|
27334
|
-
const r =
|
|
28446
|
+
const r = rayPartInto(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
|
|
28447
|
+
if (r && r.t0 < 0 && r.t1 > 0 && p.st.chipped?.length && inGap(p, toLocal(p.pos, p.q, objLocal(o, origin)))) {
|
|
28448
|
+
r.t0 = 0;
|
|
28449
|
+
r.n = vec.scale(d, -1);
|
|
28450
|
+
}
|
|
27335
28451
|
if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
|
|
27336
28452
|
if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
27337
28453
|
if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
27338
|
-
|
|
27339
|
-
|
|
27340
|
-
|
|
28454
|
+
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))));
|
|
28455
|
+
if (cutBand) {
|
|
28456
|
+
if (passed) {
|
|
28457
|
+
passed.push({ o, p, t: r.t0 });
|
|
28458
|
+
continue;
|
|
28459
|
+
}
|
|
28460
|
+
const bar2 = skip.body ? barAlong(o, p, origin, d, r.t0, r.t1) : null;
|
|
28461
|
+
if (bar2 === null) continue;
|
|
28462
|
+
r.t0 = bar2;
|
|
28463
|
+
r.n = vec.scale(d, -1);
|
|
27341
28464
|
}
|
|
27342
|
-
const
|
|
28465
|
+
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;
|
|
28466
|
+
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;
|
|
27343
28467
|
if (gap === "through") continue;
|
|
27344
28468
|
if (gap) {
|
|
27345
28469
|
r.t0 = gap.t;
|
|
@@ -27353,17 +28477,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27353
28477
|
}
|
|
27354
28478
|
}
|
|
27355
28479
|
if (!best || r.t0 < best.distance) {
|
|
27356
|
-
|
|
27357
|
-
|
|
27358
|
-
|
|
28480
|
+
if (p.castIn) {
|
|
28481
|
+
const point = vec.madd(origin, d, r.t0);
|
|
28482
|
+
const normal = copyOf2(r.n);
|
|
28483
|
+
const member = castMemberAt(o, { p, point, normal, dir: d, pathLen: r.t1 - r.t0 }, origin, d);
|
|
28484
|
+
best = member ? keepBest(into, o.id, member.p.spec.id, member.point, member.normal, r.t0, member.pathLen) : keepBest(into, o.id, p.spec.id, point, normal, r.t0, r.t1 - r.t0);
|
|
28485
|
+
} else {
|
|
28486
|
+
rayPoint[0] = origin[0] + d[0] * r.t0;
|
|
28487
|
+
rayPoint[1] = origin[1] + d[1] * r.t0;
|
|
28488
|
+
rayPoint[2] = origin[2] + d[2] * r.t0;
|
|
28489
|
+
best = keepBest(into, o.id, p.spec.id, rayPoint, r.n, r.t0, r.t1 - r.t0);
|
|
28490
|
+
}
|
|
27359
28491
|
}
|
|
27360
28492
|
}
|
|
27361
28493
|
}
|
|
27362
|
-
|
|
28494
|
+
const hosted = worldOnly ? NO_IMPLS : scope2 ? scope2.impls : implsInOrder();
|
|
28495
|
+
for (let ii = 0; ii < hosted.length; ii++) {
|
|
28496
|
+
const im = hosted[ii];
|
|
27363
28497
|
if (counts) counts.objectVisits++;
|
|
27364
28498
|
if (!scope2 && broadPhase && rayMissesBounds(origin, d, maxDist, implBoundsOf(im))) continue;
|
|
27365
28499
|
let boxHit = null;
|
|
27366
|
-
|
|
28500
|
+
const implParts2 = scope2?.implParts.get(im) ?? im.impl.describe().parts;
|
|
28501
|
+
for (let si = 0; si < implParts2.length; si++) {
|
|
28502
|
+
const ps = implParts2[si];
|
|
27367
28503
|
if (counts) counts.partVisits++;
|
|
27368
28504
|
if (ignore?.has(`${im.impl.id}\0${ps.id}`)) continue;
|
|
27369
28505
|
if (counts) {
|
|
@@ -27371,21 +28507,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27371
28507
|
counts.shapeTested.add(im.impl.id);
|
|
27372
28508
|
}
|
|
27373
28509
|
const ov = im.poses.get(ps.id);
|
|
27374
|
-
const r =
|
|
28510
|
+
const r = rayPartInto(im.position, im.rotation, ps, ov?.q ?? specTurnOf(ps), origin, d, ov?.pos ?? ps.position);
|
|
27375
28511
|
if (!r || r.t1 < 0 || r.t0 > maxDist) continue;
|
|
27376
28512
|
if (r.t0 < 0) {
|
|
27377
|
-
if (precise && im.impl.surfaceRay) boxHit = boxHit ?? { object: im.impl.id, part: ps.id, point: origin, normal: r.n, distance: 0, pathLen: r.t1 };
|
|
28513
|
+
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 };
|
|
27378
28514
|
continue;
|
|
27379
28515
|
}
|
|
27380
|
-
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 };
|
|
28516
|
+
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 };
|
|
27381
28517
|
}
|
|
27382
28518
|
if (!boxHit) continue;
|
|
27383
28519
|
if (precise && im.impl.surfaceRay) {
|
|
27384
28520
|
const far = best ? Math.min(maxDist, best.distance) : maxDist;
|
|
27385
28521
|
const implId = im.impl.id;
|
|
27386
28522
|
const s = im.impl.surfaceRay({ origin, direction: d, maxDistance: far, ...ignore ? { ignored: (part) => ignore.has(`${implId}\0${part}`) } : {} });
|
|
27387
|
-
if (s && (!best || s.distance < best.distance)) best =
|
|
27388
|
-
} else if (!best || boxHit.distance < best.distance) best = boxHit;
|
|
28523
|
+
if (s && (!best || s.distance < best.distance)) best = keepBest(into, implId, s.part, s.point, s.normal, s.distance, s.pathLen);
|
|
28524
|
+
} else if (!best || boxHit.distance < best.distance) best = into ? keepBest(into, boxHit.object, boxHit.part, boxHit.point, boxHit.normal, boxHit.distance, boxHit.pathLen) : boxHit;
|
|
27389
28525
|
}
|
|
27390
28526
|
return best;
|
|
27391
28527
|
};
|
|
@@ -27743,10 +28879,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27743
28879
|
const sides = [0, 1, 2].sort((x, y) => A.max[y] - A.min[y] - (A.max[x] - A.min[x])).slice(0, 2);
|
|
27744
28880
|
return sides.every((k) => face(k) >= PLATE_BACK_SHARE);
|
|
27745
28881
|
};
|
|
27746
|
-
const bondCarriers = (o, p) => {
|
|
27747
|
-
if (!bondedPlate(o, p)) return [];
|
|
27748
|
-
return (o.byPart.get(p.spec.id) ?? []).filter((j) => !j.st.open && bondsPlate(o, j)).map((j) => o.parts[j.ia] === p ? o.parts[j.ib] : o.parts[j.ia]).filter((q) => !isLost(q));
|
|
27749
|
-
};
|
|
27750
28882
|
const bondedShareLeft = (p) => {
|
|
27751
28883
|
const whole2 = p.st.mass + (p.rt.removed ?? 0);
|
|
27752
28884
|
return whole2 > 0 ? p.st.mass / whole2 : 0;
|
|
@@ -27853,8 +28985,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27853
28985
|
const dv = lp[v] - (ap.offset?.[1] ?? 0);
|
|
27854
28986
|
if (Math.abs(du) > ap.size[0] / 2 || Math.abs(dv) > ap.size[1] / 2) return false;
|
|
27855
28987
|
if (!ap.bars || ap.bars.spacing <= 0) return true;
|
|
27856
|
-
const
|
|
27857
|
-
return Math.abs(
|
|
28988
|
+
const along3 = ap.bars.axis === 0 ? du + ap.size[0] / 2 : dv + ap.size[1] / 2;
|
|
28989
|
+
return Math.abs(along3 - Math.round(along3 / ap.bars.spacing) * ap.bars.spacing) > ap.bars.width / 2;
|
|
27858
28990
|
});
|
|
27859
28991
|
};
|
|
27860
28992
|
const breachAreaOf = (p, damage, blast) => damage / (p.mat.hpPerKg * p.mat.density) / Math.max(p.thickness, 5e-3) * (blast ? breachBlastFactor : 1);
|
|
@@ -27867,6 +28999,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27867
28999
|
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])];
|
|
27868
29000
|
};
|
|
27869
29001
|
const FRAGMENT_SHAPE = { shatter: "shard", splinter: "splinter", tear: "scrap" };
|
|
29002
|
+
const shardsOfCell = (cell, u, v) => {
|
|
29003
|
+
const own = createRng2(seedOf2(cell.center[0], cell.center[1], cell.center[2]));
|
|
29004
|
+
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();
|
|
29005
|
+
const out = [];
|
|
29006
|
+
for (const [a0, a1] of [[0, cu], [cu, 1]]) for (const [b0, b1] of [[0, cv], [cv, 1]]) {
|
|
29007
|
+
const size = [cell.size[0], cell.size[1], cell.size[2]];
|
|
29008
|
+
const center = [cell.center[0], cell.center[1], cell.center[2]];
|
|
29009
|
+
size[u] = cell.size[u] * (a1 - a0);
|
|
29010
|
+
size[v] = cell.size[v] * (b1 - b0);
|
|
29011
|
+
center[u] = cell.center[u] - cell.size[u] / 2 + cell.size[u] * (a0 + a1) / 2;
|
|
29012
|
+
center[v] = cell.center[v] - cell.size[v] / 2 + cell.size[v] * (b0 + b1) / 2;
|
|
29013
|
+
out.push({ ...cell, center, size });
|
|
29014
|
+
}
|
|
29015
|
+
return out;
|
|
29016
|
+
};
|
|
27870
29017
|
const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false, knownHoles, drive = CHIP_DRIVE) => {
|
|
27871
29018
|
const { c, q } = partXf(o, p);
|
|
27872
29019
|
const holes = knownHoles ?? (p.st.holes.length > 0 ? localHolesOf(p) : []);
|
|
@@ -27875,7 +29022,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27875
29022
|
const total = cells.reduce((sum2, cell) => sum2 + faceArea(cell), 0) || 1;
|
|
27876
29023
|
const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
|
|
27877
29024
|
const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
|
|
27878
|
-
|
|
29025
|
+
const pieces = shape === "shard" && bondedPlate(o, p) ? cells.flatMap((cell) => shardsOfCell(cell, u, v)) : cells;
|
|
29026
|
+
return pieces.map((cell, i) => {
|
|
27879
29027
|
const cw = toWorld(c, q, cell.center);
|
|
27880
29028
|
const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
|
|
27881
29029
|
const dv = dir ? vec.normalize(vec.madd(out, dir, drive)) : out;
|
|
@@ -28048,11 +29196,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28048
29196
|
const toPart = quat.conjugate(p.q);
|
|
28049
29197
|
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
28050
29198
|
const ld = rotateVec(toPart, objLocalDir(o, d));
|
|
28051
|
-
const
|
|
29199
|
+
const EPS33 = 1e-4;
|
|
28052
29200
|
let t = t0;
|
|
28053
29201
|
let axis2 = -1;
|
|
28054
29202
|
for (let step = 0; step < cells.length + 1; step++) {
|
|
28055
|
-
const at4 = vec.madd(lo, ld, t +
|
|
29203
|
+
const at4 = vec.madd(lo, ld, t + EPS33);
|
|
28056
29204
|
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);
|
|
28057
29205
|
if (!cell) break;
|
|
28058
29206
|
let out = Infinity;
|
|
@@ -28065,56 +29213,65 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28065
29213
|
axis2 = a;
|
|
28066
29214
|
}
|
|
28067
29215
|
}
|
|
28068
|
-
if (!Number.isFinite(out) || out >= t1 -
|
|
28069
|
-
t = out + 2 *
|
|
29216
|
+
if (!Number.isFinite(out) || out >= t1 - EPS33) return "through";
|
|
29217
|
+
t = out + 2 * EPS33;
|
|
28070
29218
|
}
|
|
28071
29219
|
if (axis2 < 0) return null;
|
|
28072
29220
|
const local2 = [0, 0, 0];
|
|
28073
29221
|
local2[axis2] = -Math.sign(ld[axis2]);
|
|
28074
29222
|
return { t, n: rotateVec(o.st.rotation, rotateVec(p.q, local2)) };
|
|
28075
29223
|
};
|
|
29224
|
+
const coreBehind = (o, p, origin, d, t0, t1) => {
|
|
29225
|
+
const gap = pastChips(o, p, origin, d, t0, t1);
|
|
29226
|
+
const core = Math.min(t1, t0 + REBAR_COVER);
|
|
29227
|
+
if (gap === null || gap !== "through" && gap.t <= core) return gap;
|
|
29228
|
+
return { t: core, n: vec.scale(d, -1) };
|
|
29229
|
+
};
|
|
29230
|
+
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);
|
|
29231
|
+
const coreStands = (p, lp) => {
|
|
29232
|
+
if (!p.spec.reinforcement || !isMember(p.dims, p.spec.structure?.role) || p.st.stripped) return false;
|
|
29233
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
29234
|
+
const bands = Math.max(1, Math.round(p.dims[along3] / MEMBER_BAND));
|
|
29235
|
+
const band = clamp2(Math.floor((lp[along3] + p.dims[along3] / 2) / p.dims[along3] * bands), 0, bands - 1);
|
|
29236
|
+
return (p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS;
|
|
29237
|
+
};
|
|
28076
29238
|
const insideChip = (p, objectPoint) => {
|
|
28077
29239
|
const cells = p.st.chipped;
|
|
28078
29240
|
if (!cells?.length) return false;
|
|
28079
29241
|
const [u, v] = planeAxes(p.thin);
|
|
28080
29242
|
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
28081
|
-
if (
|
|
28082
|
-
const along2 = p.dims.indexOf(Math.max(...p.dims));
|
|
28083
|
-
const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
|
|
28084
|
-
const band = clamp2(Math.floor((lp[along2] + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
|
|
28085
|
-
if ((p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS) return false;
|
|
28086
|
-
}
|
|
29243
|
+
if (coreStands(p, lp)) return false;
|
|
28087
29244
|
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);
|
|
28088
29245
|
};
|
|
28089
|
-
const alongAt = (
|
|
29246
|
+
const alongAt = (along3, at4) => {
|
|
28090
29247
|
const point = [0, 0, 0];
|
|
28091
|
-
point[
|
|
29248
|
+
point[along3] = at4;
|
|
28092
29249
|
return point;
|
|
28093
29250
|
};
|
|
28094
29251
|
const wornLocally = (p) => !!p.spec.reinforcement && !!p.spec.units && p.spec.units.mortar === p.spec.material && isMember(p.dims, p.spec.structure?.role) && p.spec.shape.kind === "box";
|
|
28095
29252
|
const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
|
|
28096
29253
|
var _a, _b, _c;
|
|
28097
29254
|
if (!p.spec.reinforcement || !p.spec.units || !isMember(p.dims, p.spec.structure?.role) || p.st.stripped || isLost(p) || p.spec.shape.kind !== "box") return false;
|
|
28098
|
-
const
|
|
29255
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
28099
29256
|
const lp = toLocal(p.pos, p.q, objLocal(o, entry2));
|
|
28100
29257
|
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
28101
29258
|
let depth = Infinity;
|
|
28102
|
-
for (let a = 0; a < 3; a++) if (a !==
|
|
29259
|
+
for (let a = 0; a < 3; a++) if (a !== along3 && Math.abs(ld[a]) > 1e-3) depth = Math.min(depth, p.dims[a] / Math.abs(ld[a]));
|
|
28103
29260
|
if (!Number.isFinite(depth)) return true;
|
|
28104
29261
|
const into = (penMm ?? E / Math.max(p.mat.penetration, 1e-6)) / 1e3;
|
|
28105
29262
|
const h = Math.min(into, depth);
|
|
28106
29263
|
const r = Math.min(MEMBER_CRATER_CALIBRES * caliber / 1e3, h);
|
|
28107
29264
|
const volume = Math.PI / 3 * r * r * h;
|
|
28108
|
-
const section = p.dims.reduce((product2, size, a) => a ===
|
|
28109
|
-
const bands = Math.max(1, Math.round(p.dims[
|
|
28110
|
-
const band = clamp2(Math.floor((lp[
|
|
28111
|
-
const height = p.dims[
|
|
29265
|
+
const section = p.dims.reduce((product2, size, a) => a === along3 ? product2 : product2 * size, 1);
|
|
29266
|
+
const bands = Math.max(1, Math.round(p.dims[along3] / MEMBER_BAND));
|
|
29267
|
+
const band = clamp2(Math.floor((lp[along3] + p.dims[along3] / 2) / p.dims[along3] * bands), 0, bands - 1);
|
|
29268
|
+
const height = p.dims[along3] / bands;
|
|
28112
29269
|
const worn = (_a = p.rt).bands ?? (_a.bands = {});
|
|
28113
29270
|
const before = worn[band] ?? 0;
|
|
28114
29271
|
const after2 = Math.min(1, before + volume / (section * height));
|
|
28115
29272
|
worn[band] = after2;
|
|
28116
29273
|
markDamaged(p);
|
|
28117
|
-
const bandCenter = -p.dims[
|
|
29274
|
+
const bandCenter = -p.dims[along3] / 2 + (band + 0.5) * height;
|
|
28118
29275
|
const grid = gridOf(p);
|
|
28119
29276
|
const gone = (_b = p.rt).chips ?? (_b.chips = {});
|
|
28120
29277
|
if (before >= MEMBER_CUT_LOSS || after2 < MEMBER_CUT_LOSS) {
|
|
@@ -28131,11 +29288,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28131
29288
|
const out = [];
|
|
28132
29289
|
for (let i = 0; i < grid.length; i++) {
|
|
28133
29290
|
if (gone[i] === -1) continue;
|
|
28134
|
-
if (Math.abs(grid[i].center[
|
|
29291
|
+
if (Math.abs(grid[i].center[along3] - bandCenter) <= height / 2 + 1e-6) out.push(i);
|
|
28135
29292
|
}
|
|
28136
29293
|
worn[band] = 1;
|
|
28137
29294
|
if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src, d);
|
|
28138
|
-
giveAtCut(o, p, src, { at: alongAt(
|
|
29295
|
+
giveAtCut(o, p, src, { at: alongAt(along3, bandCenter), d });
|
|
28139
29296
|
return true;
|
|
28140
29297
|
};
|
|
28141
29298
|
const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
|
|
@@ -28227,8 +29384,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28227
29384
|
const lo = cell.center[a] - cell.size[a] / 2, hi = cell.center[a] + cell.size[a] / 2;
|
|
28228
29385
|
const free = (side, sign2) => {
|
|
28229
29386
|
if (sign2 > 0 ? side >= half - 1e-6 : side <= -half + 1e-6) return sign2 > 0 || a !== planeAxes(p.thin)[1];
|
|
28230
|
-
const
|
|
28231
|
-
return gridOf(p).some((c, k) => gone(k) && Math.abs(
|
|
29387
|
+
const probe2 = side + sign2 * 1e-3;
|
|
29388
|
+
return gridOf(p).some((c, k) => gone(k) && Math.abs(probe2 - c.center[a]) <= c.size[a] / 2 && Math.abs(cell.center[b] - c.center[b]) <= c.size[b] / 2);
|
|
28232
29389
|
};
|
|
28233
29390
|
if (at4 - lo <= reach2 && free(lo, -1)) return [lo, Math.max(crater2[1], lo)];
|
|
28234
29391
|
if (hi - at4 <= reach2 && free(hi, 1)) return [Math.min(crater2[0], hi), hi];
|
|
@@ -28330,18 +29487,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28330
29487
|
if (reinforcement) exposeRebar(o, p, src);
|
|
28331
29488
|
if (p.structural) solveStructure(o);
|
|
28332
29489
|
};
|
|
28333
|
-
const blastReachOf = (
|
|
28334
|
-
const resistance = Math.max(1,
|
|
29490
|
+
const blastReachOf = (p, energy) => {
|
|
29491
|
+
const resistance = Math.max(1, (p.mat.hits?.blunt?.unitJoules ?? chipEnergy) * p.mat.density * p.thickness);
|
|
28335
29492
|
return BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3) * clamp2(Math.cbrt(BLAST_REFERENCE_RESISTANCE / resistance), 0.3, 2);
|
|
28336
29493
|
};
|
|
28337
29494
|
const blastUnits = (o, p, wp, energy, dist2, src, from) => {
|
|
28338
29495
|
var _a;
|
|
28339
29496
|
if (!p.staged && !bondedPlate(o, p) || p.st.stripped || isLost(p) || chipEnergy <= 0) return false;
|
|
28340
|
-
const reach2 = blastReachOf(
|
|
29497
|
+
const reach2 = blastReachOf(p, energy);
|
|
28341
29498
|
if (dist2 >= reach2) return false;
|
|
28342
|
-
const radius = Math.sqrt(reach2 * reach2 - dist2 * dist2);
|
|
28343
29499
|
const [u, v] = planeAxes(p.thin);
|
|
28344
|
-
const
|
|
29500
|
+
const charge2 = from ? toLocal(p.pos, p.q, objLocal(o, from)) : null;
|
|
29501
|
+
const lp = charge2 ?? toLocal(p.pos, p.q, objLocal(o, wp));
|
|
29502
|
+
const off = charge2 ? Math.max(0, Math.abs(charge2[p.thin]) - p.dims[p.thin] / 2) : dist2;
|
|
29503
|
+
const radius = Math.sqrt(Math.max(0, reach2 * reach2 - off * off));
|
|
28345
29504
|
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
28346
29505
|
const grid = gridOf(p);
|
|
28347
29506
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
@@ -28520,19 +29679,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28520
29679
|
};
|
|
28521
29680
|
const cutBandsGone = (o, p, cells, d, src) => {
|
|
28522
29681
|
var _a;
|
|
28523
|
-
const
|
|
28524
|
-
const bands = Math.max(1, Math.round(p.dims[
|
|
28525
|
-
const height = p.dims[
|
|
28526
|
-
const bandOf2 = (at4) => clamp2(Math.floor((at4 + p.dims[
|
|
29682
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
29683
|
+
const bands = Math.max(1, Math.round(p.dims[along3] / MEMBER_BAND));
|
|
29684
|
+
const height = p.dims[along3] / bands;
|
|
29685
|
+
const bandOf2 = (at4) => clamp2(Math.floor((at4 + p.dims[along3] / 2) / p.dims[along3] * bands), 0, bands - 1);
|
|
28527
29686
|
const grid = gridOf(p);
|
|
28528
29687
|
const gone = p.rt.chips ?? {};
|
|
28529
29688
|
const worn = (_a = p.rt).bands ?? (_a.bands = {});
|
|
28530
|
-
for (const band of new Set(cells.map((cell) => bandOf2(cell.center[
|
|
29689
|
+
for (const band of new Set(cells.map((cell) => bandOf2(cell.center[along3])))) {
|
|
28531
29690
|
if ((worn[band] ?? 0) >= 1) continue;
|
|
28532
|
-
const center = -p.dims[
|
|
28533
|
-
if (!grid.every((cell, i) => gone[i] === -1 || Math.abs(cell.center[
|
|
29691
|
+
const center = -p.dims[along3] / 2 + (band + 0.5) * height;
|
|
29692
|
+
if (!grid.every((cell, i) => gone[i] === -1 || Math.abs(cell.center[along3] - center) > height / 2 + 1e-6)) continue;
|
|
28534
29693
|
worn[band] = 1;
|
|
28535
|
-
return giveAtCut(o, p, src, { at: alongAt(
|
|
29694
|
+
return giveAtCut(o, p, src, { at: alongAt(along3, center), d });
|
|
28536
29695
|
}
|
|
28537
29696
|
return false;
|
|
28538
29697
|
};
|
|
@@ -28577,14 +29736,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28577
29736
|
const r = p.spec.reinforcement;
|
|
28578
29737
|
if (!r) return 0;
|
|
28579
29738
|
const left = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length - (p.rt.severedBars?.length ?? 0);
|
|
28580
|
-
const
|
|
28581
|
-
const side = Math.min(...p.dims.filter((_, a) => a !==
|
|
29739
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
29740
|
+
const side = Math.min(...p.dims.filter((_, a) => a !== along3));
|
|
28582
29741
|
const fy = (materials.get(r.material)?.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
|
|
28583
29742
|
return Math.max(0, left) / 2 * Math.PI * (r.diameter / 2) ** 2 * fy * Math.max(0, side - 2 * REBAR_COVER);
|
|
28584
29743
|
};
|
|
28585
29744
|
const memberSide = (p) => {
|
|
28586
|
-
const
|
|
28587
|
-
return Math.min(...p.dims.filter((_, a) => a !==
|
|
29745
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
29746
|
+
return Math.min(...p.dims.filter((_, a) => a !== along3));
|
|
28588
29747
|
};
|
|
28589
29748
|
const tubeMoment = (p, share) => {
|
|
28590
29749
|
const [a = 0, b = 0] = [...p.dims].sort((x, y) => x - y);
|
|
@@ -28623,12 +29782,61 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28623
29782
|
emit2({ ...base2(o, src), type: "yield", part: p.spec.id, joint: h.joint, point, toward: rotateVec(o.st.rotation, h.toward), moment: h.moment });
|
|
28624
29783
|
}
|
|
28625
29784
|
};
|
|
29785
|
+
const barAlong = (o, p, origin, d, t0, t1) => {
|
|
29786
|
+
const r = p.spec.reinforcement;
|
|
29787
|
+
if (!r || !isMember(p.dims, p.spec.structure?.role)) return null;
|
|
29788
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
29789
|
+
const [u, v] = [0, 1, 2].filter((k) => k !== along3);
|
|
29790
|
+
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
29791
|
+
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
29792
|
+
const across2 = Math.hypot(ld[u], ld[v]);
|
|
29793
|
+
if (across2 < 1e-6) return null;
|
|
29794
|
+
const cut = p.rt.severedBars ?? [];
|
|
29795
|
+
let best = null;
|
|
29796
|
+
rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a], i) => {
|
|
29797
|
+
if (cut.includes(i)) return;
|
|
29798
|
+
const du = a[u] - lo[u];
|
|
29799
|
+
const dv = a[v] - lo[v];
|
|
29800
|
+
if (Math.abs(du * ld[v] - dv * ld[u]) / across2 > r.diameter / 2) return;
|
|
29801
|
+
const t = (du * ld[u] + dv * ld[v]) / (across2 * across2);
|
|
29802
|
+
if (t >= t0 && t <= t1 && (best === null || t < best)) best = t;
|
|
29803
|
+
});
|
|
29804
|
+
return best;
|
|
29805
|
+
};
|
|
29806
|
+
const cutCageBars = (o, p, origin, d, caliber, src) => {
|
|
29807
|
+
var _a;
|
|
29808
|
+
const r = p.spec.reinforcement;
|
|
29809
|
+
if (!r || isLost(p)) return;
|
|
29810
|
+
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
29811
|
+
const ld = vec.normalize(rotateVec(quat.conjugate(p.q), objLocalDir(o, d)));
|
|
29812
|
+
const reach2 = r.diameter / 2 + caliber / 2e3;
|
|
29813
|
+
const cut = (_a = p.rt).severedBars ?? (_a.severedBars = []);
|
|
29814
|
+
let severed = 0;
|
|
29815
|
+
rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a, b], i) => {
|
|
29816
|
+
if (cut.includes(i)) return;
|
|
29817
|
+
const near = lineToSegment(lo, ld, a, b);
|
|
29818
|
+
if (!near || near.distance > reach2) return;
|
|
29819
|
+
cut.push(i);
|
|
29820
|
+
severed++;
|
|
29821
|
+
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);
|
|
29822
|
+
});
|
|
29823
|
+
if (severed === 0) return;
|
|
29824
|
+
markDamaged(p);
|
|
29825
|
+
if (cageLeft(p) <= 0) {
|
|
29826
|
+
if (p.rt.hinges?.length) reyield(o, p, 0, src);
|
|
29827
|
+
loseCage(o, p, src);
|
|
29828
|
+
return;
|
|
29829
|
+
}
|
|
29830
|
+
if (p.rt.hinges?.length) reyield(o, p, barsMoment(p), src);
|
|
29831
|
+
solveStructure(o);
|
|
29832
|
+
collapseCheck(o, src);
|
|
29833
|
+
};
|
|
28626
29834
|
const severBars = (o, p, origin, d, caliber, src) => {
|
|
28627
29835
|
var _a;
|
|
28628
29836
|
const r = p.spec.reinforcement;
|
|
28629
29837
|
if (!r || isLost(p) || !isMember(p.dims, p.spec.structure?.role)) return;
|
|
28630
|
-
const
|
|
28631
|
-
const [u, v] = [0, 1, 2].filter((k) => k !==
|
|
29838
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
29839
|
+
const [u, v] = [0, 1, 2].filter((k) => k !== along3);
|
|
28632
29840
|
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
28633
29841
|
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
28634
29842
|
const across2 = Math.hypot(ld[u], ld[v]);
|
|
@@ -28722,7 +29930,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28722
29930
|
return;
|
|
28723
29931
|
}
|
|
28724
29932
|
if (p.bend) settleStructure(o);
|
|
28725
|
-
if (!force && p.bend && (p.st.flexure ?? 0) > 1 &&
|
|
29933
|
+
if (!force && p.bend && (p.st.flexure ?? 0) > 1 && sectionOf22(p, p.bend.gravity).reinforced) {
|
|
28726
29934
|
hingeDrop(o, p, src);
|
|
28727
29935
|
return;
|
|
28728
29936
|
}
|
|
@@ -28739,7 +29947,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28739
29947
|
const hitLocal = toLocal(c, q, hitW);
|
|
28740
29948
|
const unitPlan = p.spec.units ? unitFragmentPlan(p, maxFragments * UNIT_FRAGMENT_FACTOR) : [];
|
|
28741
29949
|
const axis2 = style === "splinter" || style === "snap" ? severAxis(p) : -1;
|
|
28742
|
-
const
|
|
29950
|
+
const cutAt3 = axis2 < 0 ? void 0 : p.rt.cutAt ?? (origin ? hitLocal[axis2] : void 0);
|
|
28743
29951
|
const planRnd = p.mat.splitForm ? splitStream(o.id, p.spec.id, hitLocal) : rnd2;
|
|
28744
29952
|
const plan = unitPlan.length > 0 ? unitPlan : planFragments({
|
|
28745
29953
|
style,
|
|
@@ -28752,7 +29960,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28752
29960
|
rnd: planRnd,
|
|
28753
29961
|
sheet: p.mat.sheet,
|
|
28754
29962
|
...p.mat.splitForm ? { form: p.mat.splitForm } : {},
|
|
28755
|
-
...
|
|
29963
|
+
...cutAt3 !== void 0 ? { cut: { at: cutAt3, gap: SEVER_BAND } } : {},
|
|
28756
29964
|
...p.spec.solids ? { solids: p.spec.solids } : {}
|
|
28757
29965
|
});
|
|
28758
29966
|
const holes = p.st.holes.length > 0 ? localHolesOf(p) : [];
|
|
@@ -28829,9 +30037,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28829
30037
|
};
|
|
28830
30038
|
const bandOf = (o, p, axis2, origin) => {
|
|
28831
30039
|
const { c, q } = partXf(o, p);
|
|
28832
|
-
const
|
|
30040
|
+
const along3 = toLocal(c, q, origin)[axis2];
|
|
28833
30041
|
const L = p.dims[axis2];
|
|
28834
|
-
return clamp2(Math.floor((
|
|
30042
|
+
return clamp2(Math.floor((along3 + L / 2) / SEVER_BAND), 0, Math.ceil(L / SEVER_BAND) - 1);
|
|
28835
30043
|
};
|
|
28836
30044
|
const applyDamage = (o, p, amount, type, origin, dir, fragEnergy, cap, src, weight = 1, section = 1) => {
|
|
28837
30045
|
var _a;
|
|
@@ -28900,7 +30108,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28900
30108
|
const fibre = tear === "lumps";
|
|
28901
30109
|
const strips = tear === "strips";
|
|
28902
30110
|
const { q } = partXf(o, p);
|
|
28903
|
-
const
|
|
30111
|
+
const along3 = (p.spec.grain ? AXIS[p.spec.grain] : void 0) ?? [0, 1, 2].sort((a, b) => p.dims[b] - p.dims[a])[0];
|
|
28904
30112
|
const fragments = [];
|
|
28905
30113
|
for (let i = 0; i < n; i++) {
|
|
28906
30114
|
const back2 = !exit || i % 3 === 2;
|
|
@@ -28908,9 +30116,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28908
30116
|
const len = scale * (fibre ? 1.2 + 1.2 * rnd2() : strips ? 6 + 6 * rnd2() : 3 + 4 * rnd2()), w = scale * (strips ? 1 + rnd2() : 0.8 + 0.8 * rnd2());
|
|
28909
30117
|
const t = strips ? Math.min(p.thickness, STRIP_THICKNESS) : scale * (fibre ? 0.7 + 0.6 * rnd2() : plies ? 0.15 + 0.15 * rnd2() : 0.4 + 0.4 * rnd2());
|
|
28910
30118
|
const size = [w, w, w];
|
|
28911
|
-
size[
|
|
28912
|
-
size[(
|
|
28913
|
-
size[(
|
|
30119
|
+
size[along3] = len;
|
|
30120
|
+
size[(along3 + 1) % 3] = w;
|
|
30121
|
+
size[(along3 + 2) % 3] = t;
|
|
28914
30122
|
const spread3 = [(rnd2() - 0.5) * 0.8, (rnd2() - 0.2) * 0.8, (rnd2() - 0.5) * 0.8];
|
|
28915
30123
|
const speed = shot ? back2 ? 1.5 + 2 * rnd2() : 2 + 4 * rnd2() : 0.8 + 1.2 * rnd2();
|
|
28916
30124
|
const v = vec.scale(vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3)), speed);
|
|
@@ -28937,6 +30145,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28937
30145
|
const piece3 = round5.piece;
|
|
28938
30146
|
const weight = piece3?.weight ?? 1;
|
|
28939
30147
|
const piercing = round5.piercing ?? 1;
|
|
30148
|
+
if (p.st.stripped && p.spec.reinforcement) cutCageBars(o, p, entry2, d, caliber, src);
|
|
28940
30149
|
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))))) {
|
|
28941
30150
|
return { penetrated: true, exitEnergy: E, exitPoint: vec.madd(entry2, d, Math.min(pathLen, p.thickness)), damage: 0 };
|
|
28942
30151
|
}
|
|
@@ -29049,8 +30258,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29049
30258
|
j.st.open = true;
|
|
29050
30259
|
j.st.openedBy = "break";
|
|
29051
30260
|
}
|
|
29052
|
-
const
|
|
29053
|
-
hingeAcross(o, p, opened, { at: alongAt(
|
|
30261
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
30262
|
+
hingeAcross(o, p, opened, { at: alongAt(along3, toLocal(p.pos, p.q, objLocal(o, entry2))[along3]), d, behind: memberSide(p) / 2, moment: tubeMoment(p, share) }, src);
|
|
29054
30263
|
loosened(o, opened, "break", src);
|
|
29055
30264
|
collapseCheck(o, src);
|
|
29056
30265
|
};
|
|
@@ -29413,7 +30622,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29413
30622
|
if (!r?.part) continue;
|
|
29414
30623
|
reportShelter(o, r);
|
|
29415
30624
|
out.push(r);
|
|
29416
|
-
for (const [part,
|
|
30625
|
+
for (const [part, factor2] of Object.entries(r.blast?.parts ?? {})) summary2.push({ object: o.id, part, factor: factor2 });
|
|
29417
30626
|
fragmentHits += r.blast?.fragmentHits ?? 0;
|
|
29418
30627
|
}
|
|
29419
30628
|
for (const im of impls.values()) {
|
|
@@ -29540,8 +30749,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29540
30749
|
const lineMeetsSphere = (t, point, d, range3) => {
|
|
29541
30750
|
if (t.distance - t.radius >= range3) return false;
|
|
29542
30751
|
if (t.distance <= t.radius) return true;
|
|
29543
|
-
const
|
|
29544
|
-
return
|
|
30752
|
+
const along3 = (t.centre[0] - point[0]) * d[0] + (t.centre[1] - point[1]) * d[1] + (t.centre[2] - point[2]) * d[2];
|
|
30753
|
+
return along3 > 0 && t.distance * t.distance - along3 * along3 <= t.radius * t.radius;
|
|
29545
30754
|
};
|
|
29546
30755
|
const boxDirection = [0, 0, 0];
|
|
29547
30756
|
const lineMeetsBox = (box5, d, range3) => {
|
|
@@ -30300,6 +31509,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30300
31509
|
finishExplosions();
|
|
30301
31510
|
const id = opts.id ?? impl.id;
|
|
30302
31511
|
if (taken(id)) throw new Error(`object "${id}" already exists`);
|
|
31512
|
+
implsRevision++;
|
|
30303
31513
|
impls.set(id, { impl, position: opts.position ?? [0, 0, 0], rotation: opts.rotation ?? [0, 0, 0, 1], poses: /* @__PURE__ */ new Map(), posesVersion: 0 });
|
|
30304
31514
|
return id;
|
|
30305
31515
|
},
|
|
@@ -30330,6 +31540,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30330
31540
|
if (existing) dirtyHosted.delete(existing);
|
|
30331
31541
|
dropObject(id);
|
|
30332
31542
|
impls.delete(id);
|
|
31543
|
+
implsRevision++;
|
|
30333
31544
|
},
|
|
30334
31545
|
has: (id) => taken(id),
|
|
30335
31546
|
ids: () => [...objects.keys(), ...impls.keys()],
|
|
@@ -30465,6 +31676,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30465
31676
|
const terrain = objects.get(r.object)?.parts.find((p) => p.spec.id === r.part)?.spec.tags?.includes("terrain") === true;
|
|
30466
31677
|
return { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: r.distance, ...terrain ? { terrain: true } : {} };
|
|
30467
31678
|
},
|
|
31679
|
+
raycastInto(origin, direction, maxDistance, out, options2) {
|
|
31680
|
+
const ignoredParts = options2?.ignoreParts;
|
|
31681
|
+
const ignore = ignoredParts?.length ? new Set(ignoredParts.map((ignored) => `${ignored.object}\0${ignored.part}`)) : void 0;
|
|
31682
|
+
bestInto = bestScratch;
|
|
31683
|
+
let r;
|
|
31684
|
+
try {
|
|
31685
|
+
r = raycastInternal(origin, direction, maxDistance, ignore, false, true, options2);
|
|
31686
|
+
} finally {
|
|
31687
|
+
bestInto = null;
|
|
31688
|
+
}
|
|
31689
|
+
if (!r) return false;
|
|
31690
|
+
out.object = r.object;
|
|
31691
|
+
out.part = r.part;
|
|
31692
|
+
out.point[0] = r.point[0];
|
|
31693
|
+
out.point[1] = r.point[1];
|
|
31694
|
+
out.point[2] = r.point[2];
|
|
31695
|
+
out.normal[0] = r.normal[0];
|
|
31696
|
+
out.normal[1] = r.normal[1];
|
|
31697
|
+
out.normal[2] = r.normal[2];
|
|
31698
|
+
out.distance = r.distance;
|
|
31699
|
+
out.terrain = isTerrainPart(r.object, r.part);
|
|
31700
|
+
return true;
|
|
31701
|
+
},
|
|
30468
31702
|
sweepBox(box5, direction, distance4, options2 = {}) {
|
|
30469
31703
|
const d = vec.normalize(direction);
|
|
30470
31704
|
const ignoredIds = options2.ignore === void 0 ? [] : typeof options2.ignore === "string" ? [options2.ignore] : options2.ignore;
|
|
@@ -30704,6 +31938,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30704
31938
|
return st ? clone(st) : null;
|
|
30705
31939
|
},
|
|
30706
31940
|
part: (id, partId) => objects.get(id)?.byId.get(partId)?.st ?? impls.get(id)?.impl.state().parts.find((p) => p.id === partId) ?? null,
|
|
31941
|
+
assemblyFlex(id, options2) {
|
|
31942
|
+
const o = objects.get(id);
|
|
31943
|
+
if (!o) return null;
|
|
31944
|
+
const lost = new Set(options2?.lost ?? []);
|
|
31945
|
+
const kept = new Set(o.st.groups[0] ?? []);
|
|
31946
|
+
const framed = o.parts.filter((p) => lost.has(p.spec.id) || kept.has(p.spec.id) && !isLost(p));
|
|
31947
|
+
const ids = new Set(framed.map((p) => p.spec.id));
|
|
31948
|
+
const parts2 = framed.map((p) => ({
|
|
31949
|
+
id: p.spec.id,
|
|
31950
|
+
material: p.mat,
|
|
31951
|
+
dims: p.dims,
|
|
31952
|
+
position: p.pos,
|
|
31953
|
+
rotation: p.q,
|
|
31954
|
+
// a part that went is taken whole, as it was while it held
|
|
31955
|
+
mass: lost.has(p.spec.id) ? p.mass0 : p.st.mass,
|
|
31956
|
+
...p.spec.grain ? { grain: GRAIN_AXIS[p.spec.grain] } : {},
|
|
31957
|
+
...p.spec.shape.kind === "cylinder" ? { round: true } : {}
|
|
31958
|
+
}));
|
|
31959
|
+
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 }));
|
|
31960
|
+
return assemblyFlex({ parts: parts2, joints, lost: [...lost], ...options2?.loads ? { loads: options2.loads } : {}, ...options2?.friction !== void 0 ? { friction: options2.friction } : {}, ...options2?.linear ? { linear: options2.linear } : {} });
|
|
31961
|
+
},
|
|
30707
31962
|
reset(id) {
|
|
30708
31963
|
finishExplosions();
|
|
30709
31964
|
const im = impls.get(id);
|
|
@@ -31023,17 +32278,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31023
32278
|
return new Map(w.state(id).parts.map((p) => [p.id, p.flexure ?? 0]));
|
|
31024
32279
|
};
|
|
31025
32280
|
const base2 = bending(out);
|
|
31026
|
-
const
|
|
32281
|
+
const factor2 = new Map(targets.map((p) => [p.id, (base2.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
|
|
31027
32282
|
if (options.redundancy !== void 0) {
|
|
31028
32283
|
const roles = options.redundancyRoles ?? ["column"];
|
|
31029
32284
|
for (const lost of out.parts) {
|
|
31030
32285
|
if (!lost.structure || !roles.includes(lost.structure.role)) continue;
|
|
31031
32286
|
const l = bending(without(out, lost.id));
|
|
31032
|
-
for (const p of targets) if (p.id !== lost.id)
|
|
32287
|
+
for (const p of targets) if (p.id !== lost.id) factor2.set(p.id, Math.max(factor2.get(p.id), (l.get(p.id) ?? 0) / options.redundancy));
|
|
31033
32288
|
}
|
|
31034
32289
|
}
|
|
31035
32290
|
for (const p of targets) {
|
|
31036
|
-
const f =
|
|
32291
|
+
const f = factor2.get(p.id);
|
|
31037
32292
|
const g = bendGeometry(p);
|
|
31038
32293
|
if (f <= 1 || g.gravity < 0) continue;
|
|
31039
32294
|
const section = { b: sectionWidth(g, g.gravity), h: g.dims[g.gravity] };
|
|
@@ -31699,7 +32954,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31699
32954
|
var BELOW = 0.35;
|
|
31700
32955
|
var UP = 0.15;
|
|
31701
32956
|
var END_REACH = 0.35;
|
|
31702
|
-
var
|
|
32957
|
+
var EPS23 = 1e-6;
|
|
31703
32958
|
var HOUSE_SHARING = "all";
|
|
31704
32959
|
var BEARING = 0.15;
|
|
31705
32960
|
var JAMB_CLEAR = 0.02;
|
|
@@ -31710,7 +32965,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31710
32965
|
const out = [];
|
|
31711
32966
|
for (const [a, b] of intervals.slice().sort((x, y) => x[0] - y[0])) {
|
|
31712
32967
|
const last = out[out.length - 1];
|
|
31713
|
-
if (last && a <= last[1] +
|
|
32968
|
+
if (last && a <= last[1] + EPS23) last[1] = Math.max(last[1], b);
|
|
31714
32969
|
else out.push([a, b]);
|
|
31715
32970
|
}
|
|
31716
32971
|
return out;
|
|
@@ -31851,19 +33106,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31851
33106
|
const padded = holds2(line, 0.02, wall.aabb);
|
|
31852
33107
|
if (!padded) continue;
|
|
31853
33108
|
const reach2 = context.section.along / 2;
|
|
31854
|
-
const
|
|
31855
|
-
if (
|
|
33109
|
+
const along3 = [padded[0] + (padded[0] > 0 ? PLAN_TOLERANCE + JAMB_CLEAR + reach2 : 0), padded[1] - (padded[1] < line.to - line.from ? PLAN_TOLERANCE + JAMB_CLEAR + reach2 : 0)];
|
|
33110
|
+
if (along3[1] <= along3[0]) continue;
|
|
31856
33111
|
const alongU = wall.aabb[2] - wall.aabb[0] >= wall.aabb[3] - wall.aabb[1];
|
|
31857
33112
|
const openings = context.structure.openings.filter((o) => o.wall === wall.id);
|
|
31858
33113
|
if (line.dir === "u" === alongU) {
|
|
31859
|
-
let pieces = [
|
|
33114
|
+
let pieces = [along3];
|
|
31860
33115
|
for (const o of openings) {
|
|
31861
33116
|
const a = o.from - line.from - JAMB_CLEAR - reach2;
|
|
31862
33117
|
const b = o.to - line.from + JAMB_CLEAR + reach2;
|
|
31863
33118
|
pieces = pieces.flatMap(([x, y]) => b <= x || a >= y ? [[x, y]] : [[x, a], [b, y]].filter(([p, q]) => q > p));
|
|
31864
33119
|
}
|
|
31865
33120
|
out.push(...pieces);
|
|
31866
|
-
} else if (!openings.some((o) => line.at > o.from - 0.1 && line.at < o.to + 0.1)) out.push(
|
|
33121
|
+
} else if (!openings.some((o) => line.at > o.from - 0.1 && line.at < o.to + 0.1)) out.push(along3);
|
|
31867
33122
|
}
|
|
31868
33123
|
const bottom = context.structure.levels[floor2] ?? 0;
|
|
31869
33124
|
const half = context.section.along / 2;
|
|
@@ -31881,7 +33136,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31881
33136
|
}
|
|
31882
33137
|
return { u, v, alongU };
|
|
31883
33138
|
}
|
|
31884
|
-
function
|
|
33139
|
+
function sectionOf3(structure, options) {
|
|
31885
33140
|
const unit = structure.construction.walls.unit;
|
|
31886
33141
|
return typeof unit === "string" ? pillarSectionOf(getMasonryUnit(unit)) : { across: options.columnSide, along: options.columnSide };
|
|
31887
33142
|
}
|
|
@@ -32035,13 +33290,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32035
33290
|
for (const { beam, host } of framings) rest(context, host, beam);
|
|
32036
33291
|
for (const { part: beam } of beams) {
|
|
32037
33292
|
const depth = depthToCarry(beam, context, options.beamStep);
|
|
32038
|
-
if (depth > beam.y1 - beam.y0 +
|
|
33293
|
+
if (depth > beam.y1 - beam.y0 + EPS23) deepen(beam, depth);
|
|
32039
33294
|
}
|
|
32040
33295
|
for (let changed = true, guard = 0; changed && guard < framings.length + 1; guard++) {
|
|
32041
33296
|
changed = false;
|
|
32042
33297
|
for (const { beam, host } of framings) {
|
|
32043
33298
|
const section = sectionDepthAt(host, beam.aabb, context.parts);
|
|
32044
|
-
if (section >= depthToHold(host, beam) -
|
|
33299
|
+
if (section >= depthToHold(host, beam) - EPS23 || section > host.y1 - host.y0 + EPS23) continue;
|
|
32045
33300
|
deepen(host, depthToHold(host, beam));
|
|
32046
33301
|
changed = true;
|
|
32047
33302
|
}
|
|
@@ -32100,7 +33355,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32100
33355
|
const [gu0, gv0] = pointOf(line, found.lo);
|
|
32101
33356
|
const [gu1, gv1] = pointOf(line, found.hi);
|
|
32102
33357
|
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];
|
|
32103
|
-
if (span > 1.5 && Number.isFinite(span) && sectionDepthAt(plate2, gap, context.parts) < beamDepthFor(span, options) -
|
|
33358
|
+
if (span > 1.5 && Number.isFinite(span) && sectionDepthAt(plate2, gap, context.parts) < beamDepthFor(span, options) - EPS23) {
|
|
32104
33359
|
const depth = Math.max(plate2.y1 - plate2.y0, beamDepthFor(span, options));
|
|
32105
33360
|
plate2.y0 = round2(plate2.y1 - depth);
|
|
32106
33361
|
plate2.mass = Math.max(1, Math.round((plate2.aabb[2] - plate2.aabb[0]) * (plate2.aabb[3] - plate2.aabb[1]) * depth * densityOf(plate2.material)));
|
|
@@ -32131,7 +33386,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32131
33386
|
panelsOf: /* @__PURE__ */ new Map(),
|
|
32132
33387
|
pillars: 0,
|
|
32133
33388
|
groundBase: firstColumn?.on ?? GROUND,
|
|
32134
|
-
section:
|
|
33389
|
+
section: sectionOf3(structure, options)
|
|
32135
33390
|
};
|
|
32136
33391
|
const walls = parts2.filter((p) => /^wall_/.test(p.id) && (p.role === "wall" || p.role === "partition"));
|
|
32137
33392
|
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));
|
|
@@ -32148,7 +33403,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32148
33403
|
for (const beam of context.parts) {
|
|
32149
33404
|
if (beam.role !== "beam" || beam.slab === void 0 || !/_b\d+$/.test(beam.id)) continue;
|
|
32150
33405
|
const depth = depthToCarry(beam, context, options.beamStep);
|
|
32151
|
-
if (depth > beam.y1 - beam.y0 +
|
|
33406
|
+
if (depth > beam.y1 - beam.y0 + EPS23) deepen(beam, depth);
|
|
32152
33407
|
}
|
|
32153
33408
|
return { parts: context.parts, supports: context.supports };
|
|
32154
33409
|
}
|
|
@@ -32377,9 +33632,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32377
33632
|
const capacity = input.capacities.get(id);
|
|
32378
33633
|
capacities.delete(id);
|
|
32379
33634
|
if (capacity === void 0) continue;
|
|
32380
|
-
const
|
|
32381
|
-
const length2 =
|
|
32382
|
-
for (const piece3 of split.pieces) capacities.set(piece3.id, Math.max(1, capacity *
|
|
33635
|
+
const along3 = (box22) => Math.max(box22[2] - box22[0], box22[3] - box22[1]);
|
|
33636
|
+
const length2 = along3(input.parts.find((part) => part.id === id).aabb);
|
|
33637
|
+
for (const piece3 of split.pieces) capacities.set(piece3.id, Math.max(1, capacity * along3(piece3.aabb) / length2));
|
|
32383
33638
|
}
|
|
32384
33639
|
return { ...next, capacities };
|
|
32385
33640
|
}
|
|
@@ -32395,14 +33650,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32395
33650
|
const size = part.shape.size;
|
|
32396
33651
|
const thin = size.indexOf(Math.min(...size));
|
|
32397
33652
|
if (thin === 1) return [];
|
|
32398
|
-
const [
|
|
33653
|
+
const [along3] = planeAxes2(thin);
|
|
32399
33654
|
const turn2 = part.rotation?.[1] ?? 0;
|
|
32400
33655
|
const alongU = Math.abs(Math.cos(turn2)) * size[0] + Math.abs(Math.sin(turn2)) * size[2] >= Math.abs(Math.sin(turn2)) * size[0] + Math.abs(Math.cos(turn2)) * size[2];
|
|
32401
33656
|
return windows.map((opening2) => {
|
|
32402
33657
|
const middle = (opening2.from + opening2.to) / 2;
|
|
32403
33658
|
const centre2 = alongU ? [middle, (opening2.y0 + opening2.y1) / 2, part.position[2]] : [part.position[0], (opening2.y0 + opening2.y1) / 2, middle];
|
|
32404
33659
|
const local2 = toPartFrame(part, centre2);
|
|
32405
|
-
return { size: [opening2.to - opening2.from, opening2.y1 - opening2.y0], offset: [local2[
|
|
33660
|
+
return { size: [opening2.to - opening2.from, opening2.y1 - opening2.y0], offset: [local2[along3], local2[1]] };
|
|
32406
33661
|
});
|
|
32407
33662
|
}
|
|
32408
33663
|
function withWindowApertures(spec, openings) {
|
|
@@ -32729,12 +33984,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32729
33984
|
parts2.push({ id, material: c.material, shape: box2(size), position, structure: { role: "partition" }, tags: ["infill"] });
|
|
32730
33985
|
for (const o of on) rests(joints, id, o, "mortar");
|
|
32731
33986
|
};
|
|
32732
|
-
const bay = (side, k,
|
|
33987
|
+
const bay = (side, k, along3, centre2, fixed2, length2, c1, c2) => {
|
|
32733
33988
|
const clear = length2 - g.columnSize;
|
|
32734
33989
|
const win = clear * c.window;
|
|
32735
33990
|
const pier = (clear - win) / 2;
|
|
32736
|
-
const at23 = (u) =>
|
|
32737
|
-
const size = (u, h) =>
|
|
33991
|
+
const at23 = (u) => along3 === 0 ? [u, 0, fixed2] : [fixed2, 0, u];
|
|
33992
|
+
const size = (u, h) => along3 === 0 ? [u, h, c.thickness] : [c.thickness, h, u];
|
|
32738
33993
|
const put = (name, u, h, y, centreU, on) => {
|
|
32739
33994
|
const p = at23(centreU);
|
|
32740
33995
|
wall(`infill_${f}_${side}_${k}_${name}`, size(u, h), [p[0], y, p[2]], on);
|
|
@@ -33044,8 +34299,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
33044
34299
|
const ti = given2.innerThickness ?? CORE_DEFAULTS.innerThickness;
|
|
33045
34300
|
const shaft = given2.shaft ?? CORE_DEFAULTS.shaft;
|
|
33046
34301
|
const fit = Math.max(1, Math.floor((bay[1] - 2 * CORE_CLEARANCE - 0.2 - 2 * wallThickness + ti) / (shaft + ti)));
|
|
33047
|
-
const
|
|
33048
|
-
const wanted = given2.elevators ?? Math.max(2, Math.ceil((o.coreRatio * plate2[0] * plate2[1] /
|
|
34302
|
+
const probe2 = coreSize({ ...given2, wallThickness, elevators: 2 });
|
|
34303
|
+
const wanted = given2.elevators ?? Math.max(2, Math.ceil((o.coreRatio * plate2[0] * plate2[1] / probe2[0] - 2 * wallThickness + ti) / (shaft + ti)));
|
|
33049
34304
|
const elevators = Math.max(1, Math.min(wanted, fit));
|
|
33050
34305
|
const narrow = coreSize({ ...given2, wallThickness, elevators });
|
|
33051
34306
|
const room = bay[0] - columnSize - 2 * CORE_CLEARANCE - narrow[0];
|
|
@@ -44979,7 +46234,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
44979
46234
|
],
|
|
44980
46235
|
estimated: [
|
|
44981
46236
|
"parts"
|
|
44982
|
-
]
|
|
46237
|
+
],
|
|
46238
|
+
consumable: {
|
|
46239
|
+
form: "bar",
|
|
46240
|
+
unit: "g",
|
|
46241
|
+
amount: 100,
|
|
46242
|
+
dose: 1.5,
|
|
46243
|
+
emptyKg: 0
|
|
46244
|
+
}
|
|
44983
46245
|
},
|
|
44984
46246
|
{
|
|
44985
46247
|
id: "shampoo",
|
|
@@ -44997,7 +46259,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
44997
46259
|
stack: 3,
|
|
44998
46260
|
shape: "bottle",
|
|
44999
46261
|
color: 4885200,
|
|
45000
|
-
rarity: "common"
|
|
46262
|
+
rarity: "common",
|
|
46263
|
+
consumable: {
|
|
46264
|
+
form: "liquid",
|
|
46265
|
+
unit: "ml",
|
|
46266
|
+
amount: 300,
|
|
46267
|
+
dose: 8,
|
|
46268
|
+
emptyKg: 0.044,
|
|
46269
|
+
density: 1.02
|
|
46270
|
+
}
|
|
45001
46271
|
},
|
|
45002
46272
|
{
|
|
45003
46273
|
id: "toothpaste",
|
|
@@ -45015,7 +46285,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
45015
46285
|
stack: 3,
|
|
45016
46286
|
shape: "tube",
|
|
45017
46287
|
color: 15790320,
|
|
45018
|
-
rarity: "common"
|
|
46288
|
+
rarity: "common",
|
|
46289
|
+
consumable: {
|
|
46290
|
+
form: "paste",
|
|
46291
|
+
unit: "g",
|
|
46292
|
+
amount: 90,
|
|
46293
|
+
dose: 1,
|
|
46294
|
+
emptyKg: 0.01
|
|
46295
|
+
}
|
|
45019
46296
|
},
|
|
45020
46297
|
{
|
|
45021
46298
|
id: "toothbrush",
|
|
@@ -55259,7 +56536,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
55259
56536
|
}
|
|
55260
56537
|
for (const e of planned.items) if (e.type === "lantern_lamp") e.item.on = !!e.lit;
|
|
55261
56538
|
let scratch3 = null;
|
|
55262
|
-
function
|
|
56539
|
+
function probe2(e, hinge, setback, blockedAt) {
|
|
55263
56540
|
if (!scratch3) scratch3 = GI.createWorld({ locale, strings: hh.strings, items: hh.items, loot: hh.loot, grid: false });
|
|
55264
56541
|
const it = at(e.item);
|
|
55265
56542
|
const x = it.x + Math.sin(it.ry) * setback;
|
|
@@ -55283,12 +56560,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
55283
56560
|
const better = (a, b) => a.sum > b.sum + 1e-9 || Math.abs(a.sum - b.sum) <= 1e-9 && a.min > b.min + 1e-9;
|
|
55284
56561
|
function fitDoors(e) {
|
|
55285
56562
|
if (!isBlocked2 || !householdTypes.has(e.type)) return;
|
|
55286
|
-
const standard =
|
|
56563
|
+
const standard = probe2(e, void 0, 0, isBlocked2);
|
|
55287
56564
|
if (!standard.n || standard.min >= 1) return;
|
|
55288
56565
|
let bestSide;
|
|
55289
56566
|
let m = standard;
|
|
55290
56567
|
for (const side of ["left", "right"]) {
|
|
55291
|
-
const r =
|
|
56568
|
+
const r = probe2(e, side, 0, isBlocked2);
|
|
55292
56569
|
if (better(r, m)) {
|
|
55293
56570
|
m = r;
|
|
55294
56571
|
bestSide = side;
|
|
@@ -55301,7 +56578,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
55301
56578
|
if (m.min >= 1) return;
|
|
55302
56579
|
let target = { setback: 0, r: m };
|
|
55303
56580
|
for (const setback of [0.01, 0.02, 0.03, 0.04]) {
|
|
55304
|
-
const r =
|
|
56581
|
+
const r = probe2(e, bestSide, setback, isBlocked2);
|
|
55305
56582
|
if (better(r, target.r)) target = { setback, r };
|
|
55306
56583
|
if (r.min >= 1) break;
|
|
55307
56584
|
}
|
|
@@ -56539,7 +57816,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
56539
57816
|
}
|
|
56540
57817
|
var residentialTower = residentialTowerTemplate();
|
|
56541
57818
|
|
|
56542
|
-
// ../game-floorplan-three/dist/chunk-
|
|
57819
|
+
// ../game-floorplan-three/dist/chunk-RW7ZTU76.js
|
|
56543
57820
|
var __defProp4 = Object.defineProperty;
|
|
56544
57821
|
var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
56545
57822
|
var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -57897,12 +59174,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
57897
59174
|
if (p.blocked) {
|
|
57898
59175
|
part("window_boards", [0, 0, 0], () => {
|
|
57899
59176
|
const rb = rngString(SEED() + "|" + seedKey(p.id) + "|tabua"), cx0 = alongU ? p.at : L, cz0 = alongU ? L : p.at, nT = Math.max(4, Math.round((visH - 0.3) / 0.3)), Lg = p.width + 0.34, WOODS = [8017460, 7031338, 9071172, 6177320, 7559746];
|
|
57900
|
-
const puts = (
|
|
57901
|
-
const x = alongU ?
|
|
59177
|
+
const puts = (along22, y, off, comp, alt, thickness, color2, tilt) => {
|
|
59178
|
+
const x = alongU ? along22 : L + off, z = alongU ? L + off : along22;
|
|
57902
59179
|
boxC("wood", x, y0 + y, z, comp, alt, thickness, color2, 0, alongU ? 0 : K.PE, tilt);
|
|
57903
59180
|
};
|
|
57904
|
-
const nailColor = (
|
|
57905
|
-
const x = alongU ?
|
|
59181
|
+
const nailColor = (along22, y, off) => {
|
|
59182
|
+
const x = alongU ? along22 : L + off, z = alongU ? L + off : along22;
|
|
57906
59183
|
boxC("metal", x, y0 + y, z, alongU ? 0.022 : 0.016, 0.022, alongU ? 0.016 : 0.022, 3815478);
|
|
57907
59184
|
};
|
|
57908
59185
|
for (const sd of [-1, 1]) {
|
|
@@ -58358,8 +59635,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58358
59635
|
};
|
|
58359
59636
|
const underCovering = (items, x, z, y) => items.some((o) => {
|
|
58360
59637
|
if (o.type !== "blinds" && o.type !== "curtain") return false;
|
|
58361
|
-
const co = Math.cos(o.ry || 0), si = Math.sin(o.ry || 0), dx = x - o.x, dz = z - o.z,
|
|
58362
|
-
return Math.abs(
|
|
59638
|
+
const co = Math.cos(o.ry || 0), si = Math.sin(o.ry || 0), dx = x - o.x, dz = z - o.z, along22 = dx * co - dz * si, across2 = dx * si + dz * co;
|
|
59639
|
+
return Math.abs(along22) < (o.w || 1) / 2 + COVERING_CLEAR && Math.abs(across2) < COVERING_CLEAR && y > (o.y || 0) - COVERING_CLEAR && y < (o.y || 0) + (o.h || 2.3) + COVERING_CLEAR;
|
|
58363
59640
|
});
|
|
58364
59641
|
for (const c of R.rooms) {
|
|
58365
59642
|
if (c.type === "void" || OPEN_AREA(c)) continue;
|
|
@@ -59034,9 +60311,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
59034
60311
|
const x0 = xs[i], x1 = xs[i + 1], z0 = zs[j], z1 = zs[j + 1], yb = pe(x0, z0, x1, z1);
|
|
59035
60312
|
cursor.pc = K.panelAt("slab_top", (x0 + x1) / 2, (z0 + z1) / 2);
|
|
59036
60313
|
const ex0 = free(j, i - 1) ? o : 0, ex1 = free(j, i + 1) ? o : 0, ez0 = free(j - 1, i) ? o : 0, ez1 = free(j + 1, i) ? o : 0;
|
|
59037
|
-
const
|
|
60314
|
+
const keep2 = !shared3.ctx.visorScene, parapet = [];
|
|
59038
60315
|
const lay = (box5, color2, taken) => {
|
|
59039
|
-
if (!
|
|
60316
|
+
if (!keep2 || !taken.length) {
|
|
59040
60317
|
bx("plaster", box5[0], box5[1], box5[2], box5[3], box5[4], box5[5], color2);
|
|
59041
60318
|
return;
|
|
59042
60319
|
}
|
|
@@ -59052,7 +60329,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
59052
60329
|
for (const [ok, ax0, az0, ax1, az1] of sides) if (ok) parapet.push([ax0, yb, az0, ax1, yb + pr, az1]);
|
|
59053
60330
|
lay([x0 - ex0, yb, z0 - ez0, x1 + ex1, yb + 0.03, z1 + ez1], slab, parapet);
|
|
59054
60331
|
{
|
|
59055
|
-
const wt = (shared3.ctx.r.walls.find((w) => w.exterior)?.thickness || 0.15) / 2, yc = yb - 0.2, under =
|
|
60332
|
+
const wt = (shared3.ctx.r.walls.find((w) => w.exterior)?.thickness || 0.15) / 2, yc = yb - 0.2, under = keep2 ? shared3.ctx.occupied : [];
|
|
59056
60333
|
if (free(j, i - 1)) lay([x0 - wt, yc, z0 - (free(j - 1, i) ? wt : 0), x0, yb, z1 + (free(j + 1, i) ? wt : 0)], c, under);
|
|
59057
60334
|
if (free(j, i + 1)) lay([x1, yc, z0 - (free(j - 1, i) ? wt : 0), x1 + wt, yb, z1 + (free(j + 1, i) ? wt : 0)], c, under);
|
|
59058
60335
|
if (free(j - 1, i)) lay([x0, yc, z0 - wt, x1, yb, z0], c, under);
|
|
@@ -59140,8 +60417,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
59140
60417
|
ex /= el;
|
|
59141
60418
|
ey /= el;
|
|
59142
60419
|
ez /= el;
|
|
59143
|
-
const aligned = !shared3.ctx.visorScene,
|
|
59144
|
-
const o = aligned ? [nx *
|
|
60420
|
+
const aligned = !shared3.ctx.visorScene, along22 = nx * pts[0][0] + ny * pts[0][1] + nz * pts[0][2];
|
|
60421
|
+
const o = aligned ? [nx * along22, ny * along22, nz * along22] : origin ?? pts[0], S = [], T2 = [];
|
|
59145
60422
|
for (const p of pts) {
|
|
59146
60423
|
const rx = p[0] - o[0], ry = p[1] - o[1], rz = p[2] - o[2];
|
|
59147
60424
|
S.push(rx * ex + ry * ey + rz * ez);
|
|
@@ -60004,10 +61281,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60004
61281
|
if (opening.floor > floor2 || opening.y1 === void 0) return false;
|
|
60005
61282
|
return (plan.floors[opening.floor]?.y0 ?? 0) + opening.y1 > (plan.floors[floor2]?.y0 ?? 0);
|
|
60006
61283
|
}
|
|
60007
|
-
function clearOfOpenings(plan, wall,
|
|
61284
|
+
function clearOfOpenings(plan, wall, along22, endClear = DEFAULT_END_CLEAR) {
|
|
60008
61285
|
const line = wall.axis === "u" ? wall.v0 : wall.u0;
|
|
60009
61286
|
const a0 = wall.axis === "u" ? wall.u0 : wall.v0, a1 = wall.axis === "u" ? wall.u1 : wall.v1;
|
|
60010
|
-
let at4 = endClear > DEFAULT_END_CLEAR ? Math.max(a0 + endClear, Math.min(a1 - endClear,
|
|
61287
|
+
let at4 = endClear > DEFAULT_END_CLEAR ? Math.max(a0 + endClear, Math.min(a1 - endClear, along22)) : along22;
|
|
60011
61288
|
for (const o of plan.openings) {
|
|
60012
61289
|
if (o.axis !== wall.axis || Math.abs(o.pos - line) > 0.05 || !reaches(plan, o, wall.floor)) continue;
|
|
60013
61290
|
const lo = o.at - o.width / 2 - OPENING_CLEARANCE, hi = o.at + o.width / 2 + OPENING_CLEARANCE;
|
|
@@ -60029,7 +61306,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60029
61306
|
if (!best) return null;
|
|
60030
61307
|
const { wall } = best;
|
|
60031
61308
|
const alongU = wall.axis === "u";
|
|
60032
|
-
const
|
|
61309
|
+
const along22 = clearOfOpenings(plan, wall, best.along, options.endClear);
|
|
60033
61310
|
const line = alongU ? wall.v0 : wall.u0;
|
|
60034
61311
|
const [ru, rv] = options.toward ?? [u, v];
|
|
60035
61312
|
const across2 = alongU ? rv - line : ru - line;
|
|
@@ -60039,7 +61316,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60039
61316
|
const half = (wall.thickness ?? DEFAULT_THICKNESS) / 2;
|
|
60040
61317
|
const offset = options.surface ? half + (options.diameter ?? 0.02) / 2 : half - chaseDepth(options.diameter);
|
|
60041
61318
|
const at4 = line + side * offset;
|
|
60042
|
-
return { u: alongU ?
|
|
61319
|
+
return { u: alongU ? along22 : at4, v: alongU ? at4 : along22, wall };
|
|
60043
61320
|
}
|
|
60044
61321
|
function buildingBox(plan, wall) {
|
|
60045
61322
|
if (!wall.outbuilding) return houseFootprint(plan);
|
|
@@ -60064,8 +61341,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60064
61341
|
const start = alongU ? first.u : first.v;
|
|
60065
61342
|
const tries = [start, ...Array.from({ length: Math.ceil((a1 - a0) / FEED_STEP) }, (_, k) => [start - (k + 1) * FEED_STEP, start + (k + 1) * FEED_STEP]).flat().filter((a) => a > a0 + 0.2 && a < a1 - 0.2)];
|
|
60066
61343
|
let fallback2 = null;
|
|
60067
|
-
for (const
|
|
60068
|
-
const exit = wallDrop(plan, 0, alongU ?
|
|
61344
|
+
for (const along22 of tries) {
|
|
61345
|
+
const exit = wallDrop(plan, 0, alongU ? along22 : first.u, alongU ? first.v : along22, { ...options, surface: false, walls: [wall], toward: centreOf(houseFootprint(plan)) });
|
|
60069
61346
|
if (!exit) continue;
|
|
60070
61347
|
for (const turnFirst of [false, true]) {
|
|
60071
61348
|
const feed = feedFrom(plan, exit, target, y, { ...options, turnFirst });
|
|
@@ -60285,10 +61562,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60285
61562
|
const y = rise(s) * Math.pow(Math.max(0, Math.sin(Math.PI * t / width)), 0.8) - MOUND_SINK;
|
|
60286
61563
|
return alongX ? [x0 + s, y, z0 + t] : [x0 + t, y, z0 + s];
|
|
60287
61564
|
};
|
|
60288
|
-
const
|
|
60289
|
-
for (let i = 0; i <
|
|
61565
|
+
const along22 = MOUND_GRID.along * humps, { across: across2 } = MOUND_GRID;
|
|
61566
|
+
for (let i = 0; i < along22; i++) {
|
|
60290
61567
|
for (let j = 0; j < across2; j++) {
|
|
60291
|
-
const s0 = length2 * i /
|
|
61568
|
+
const s0 = length2 * i / along22, s1 = length2 * (i + 1) / along22, t0 = width * j / across2, t1 = width * (j + 1) / across2;
|
|
60292
61569
|
const quad = [at4(s0, t0), at4(s1, t0), at4(s1, t1), at4(s0, t1)];
|
|
60293
61570
|
const e1 = [quad[1][0] - quad[0][0], quad[1][1] - quad[0][1], quad[1][2] - quad[0][2]], e2 = [quad[3][0] - quad[0][0], quad[3][1] - quad[0][1], quad[3][2] - quad[0][2]];
|
|
60294
61571
|
const up = e1[2] * e2[0] - e1[0] * e2[2];
|
|
@@ -60706,9 +61983,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60706
61983
|
}
|
|
60707
61984
|
var CAP_SINK = 2e-3;
|
|
60708
61985
|
function drawnEnds(span, previous, next) {
|
|
60709
|
-
const
|
|
61986
|
+
const along22 = [(span.b[0] - span.a[0]) / span.length, (span.b[1] - span.a[1]) / span.length, (span.b[2] - span.a[2]) / span.length];
|
|
60710
61987
|
const shift = (neighbour) => span.host !== null ? -CAP_SINK : neighbour && neighbour.host !== null ? CAP_SINK : 0;
|
|
60711
|
-
const move2 = (end3, amount) => [end3[0] +
|
|
61988
|
+
const move2 = (end3, amount) => [end3[0] + along22[0] * amount, end3[1] + along22[1] * amount, end3[2] + along22[2] * amount];
|
|
60712
61989
|
return span.length > 4 * CAP_SINK ? [move2(span.a, -shift(previous)), move2(span.b, shift(next))] : [span.a, span.b];
|
|
60713
61990
|
}
|
|
60714
61991
|
var PIPE_WALL_FILL = 0.3;
|
|
@@ -61004,21 +62281,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61004
62281
|
const defined = { drainPipes };
|
|
61005
62282
|
Object.assign(K, defined);
|
|
61006
62283
|
}
|
|
61007
|
-
var
|
|
62284
|
+
var EPS24 = 1e-4;
|
|
61008
62285
|
function subtractRects(base2, holes) {
|
|
61009
62286
|
let pieces = [base2];
|
|
61010
62287
|
for (const h of holes) {
|
|
61011
62288
|
const next = [];
|
|
61012
62289
|
for (const r of pieces) {
|
|
61013
62290
|
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);
|
|
61014
|
-
if (a1 - a0 <
|
|
62291
|
+
if (a1 - a0 < EPS24 || y1 - y0 < EPS24) {
|
|
61015
62292
|
next.push(r);
|
|
61016
62293
|
continue;
|
|
61017
62294
|
}
|
|
61018
|
-
if (a0 - r.a0 >
|
|
61019
|
-
if (r.a1 - a1 >
|
|
61020
|
-
if (y0 - r.y0 >
|
|
61021
|
-
if (r.y1 - y1 >
|
|
62295
|
+
if (a0 - r.a0 > EPS24) next.push({ a0: r.a0, a1: a0, y0: r.y0, y1: r.y1 });
|
|
62296
|
+
if (r.a1 - a1 > EPS24) next.push({ a0: a1, a1: r.a1, y0: r.y0, y1: r.y1 });
|
|
62297
|
+
if (y0 - r.y0 > EPS24) next.push({ a0, a1, y0: r.y0, y1: y0 });
|
|
62298
|
+
if (r.y1 - y1 > EPS24) next.push({ a0, a1, y0: y1, y1: r.y1 });
|
|
61022
62299
|
}
|
|
61023
62300
|
pieces = next;
|
|
61024
62301
|
}
|
|
@@ -61034,7 +62311,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61034
62311
|
const across0 = wall.alongU ? v0 : u0, across1 = wall.alongU ? v1 : u1;
|
|
61035
62312
|
const half = wall.thickness / 2;
|
|
61036
62313
|
const covered = Math.min(across1, wall.line + half) - Math.max(across0, wall.line - half);
|
|
61037
|
-
if (covered < Math.min(wall.thickness * 0.3, across1 - across0) -
|
|
62314
|
+
if (covered < Math.min(wall.thickness * 0.3, across1 - across0) - EPS24) return null;
|
|
61038
62315
|
return wall.alongU ? { a0: u0, a1: u1, y0, y1 } : { a0: v0, a1: v1, y0, y1 };
|
|
61039
62316
|
}
|
|
61040
62317
|
function addStageBox(THREE, parent, x0, y0, z0, x1, y1, z1, mat, partId) {
|
|
@@ -61285,11 +62562,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61285
62562
|
function chasesIn(wall, core, runs) {
|
|
61286
62563
|
const out = [];
|
|
61287
62564
|
for (const r of runs) {
|
|
61288
|
-
const
|
|
61289
|
-
if (
|
|
62565
|
+
const along22 = wall.alongU ? r.u : r.v, across2 = (wall.alongU ? r.v : r.u) - core.line;
|
|
62566
|
+
if (along22 + r.radius + CHASE_CLEAR2 < wall.a0 || along22 - r.radius - CHASE_CLEAR2 > wall.a1 || r.y1 <= core.y0 || r.y0 >= core.y1) continue;
|
|
61290
62567
|
if (Math.abs(across2) > wall.thickness / 2 + 1e-6) continue;
|
|
61291
62568
|
const back2 = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
|
|
61292
|
-
out.push({ a0:
|
|
62569
|
+
out.push({ a0: along22 - r.radius - CHASE_CLEAR2, a1: along22 + r.radius + CHASE_CLEAR2, y0: Math.max(core.y0, r.y0), y1: Math.min(core.y1, r.y1), side: across2 >= 0 ? 1 : -1, back: back2, ...r.box ? { box: true } : {} });
|
|
61293
62570
|
}
|
|
61294
62571
|
return out;
|
|
61295
62572
|
}
|
|
@@ -61310,11 +62587,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61310
62587
|
const bounds2 = [Math.min(...own.map((s) => s.aabb[0])), Math.min(...own.map((s) => s.aabb[1])), Math.max(...own.map((s) => s.aabb[2])), Math.max(...own.map((s) => s.aabb[3]))];
|
|
61311
62588
|
const under = carriers.filter((c) => c.floor === f && own.some((s) => overlapArea2(c.aabb, s.aabb) > EPS32 && c.y1 > s.y0 - 0.05 && c.y1 <= s.y1 + EPS32));
|
|
61312
62589
|
if (!under.length) continue;
|
|
61313
|
-
const
|
|
62590
|
+
const along22 = (alongU) => {
|
|
61314
62591
|
const own2 = under.filter((c) => beams.includes(c) && c.aabb[2] - c.aabb[0] >= c.aabb[3] - c.aabb[1] === alongU);
|
|
61315
62592
|
return own2.length ? own2 : under;
|
|
61316
62593
|
};
|
|
61317
|
-
const [acrossU, acrossV] = [
|
|
62594
|
+
const [acrossU, acrossV] = [along22(false), along22(true)];
|
|
61318
62595
|
const reach2 = [Math.min(...acrossU.map((c) => c.aabb[0])), Math.min(...acrossV.map((c) => c.aabb[1])), Math.max(...acrossU.map((c) => c.aabb[2])), Math.max(...acrossV.map((c) => c.aabb[3]))];
|
|
61319
62596
|
for (const s of own) {
|
|
61320
62597
|
for (const k of [0, 1]) if (Math.abs(s.aabb[k] - bounds2[k]) < EPS32 && reach2[k] < s.aabb[k] + SLAB_LIP && s.aabb[k] - reach2[k] < 0.3) s.aabb[k] = reach2[k] - SLAB_LIP;
|
|
@@ -61574,7 +62851,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61574
62851
|
const alongHalf = (span + size.holderAlong) / 2 + size.battenOverhang;
|
|
61575
62852
|
const across2 = size.battenWidth / 2;
|
|
61576
62853
|
const battenBase = mountY - size.battenHeight;
|
|
61577
|
-
const around = (
|
|
62854
|
+
const around = (along22, cross5) => alongU ? [x + along22, z + cross5] : [x + cross5, z + along22];
|
|
61578
62855
|
const rectangle = (along0, along1, cross0, cross1, y0, y1, color2) => {
|
|
61579
62856
|
const [ax, az] = around(along0, cross0);
|
|
61580
62857
|
const [bx, bz] = around(along1, cross1);
|
|
@@ -61627,7 +62904,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61627
62904
|
function wallBehindOf(walls, point) {
|
|
61628
62905
|
const alongU = Math.abs(point.frontV) >= Math.abs(point.frontU);
|
|
61629
62906
|
const across2 = alongU ? point.v : point.u;
|
|
61630
|
-
const
|
|
62907
|
+
const along22 = alongU ? point.u : point.v;
|
|
61631
62908
|
let best;
|
|
61632
62909
|
let bestGap = Infinity;
|
|
61633
62910
|
for (const wall of walls) {
|
|
@@ -61635,7 +62912,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61635
62912
|
const line = alongU ? wall.v0 : wall.u0;
|
|
61636
62913
|
const [from, to] = alongU ? [Math.min(wall.u0, wall.u1), Math.max(wall.u0, wall.u1)] : [Math.min(wall.v0, wall.v1), Math.max(wall.v0, wall.v1)];
|
|
61637
62914
|
const gap = Math.abs(across2 - line);
|
|
61638
|
-
if (
|
|
62915
|
+
if (along22 < from - 1e-6 || along22 > to + 1e-6 || gap > wall.thickness || gap >= bestGap) continue;
|
|
61639
62916
|
best = { line, halfThickness: wall.thickness / 2 };
|
|
61640
62917
|
bestGap = gap;
|
|
61641
62918
|
}
|
|
@@ -66322,8 +67599,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66322
67599
|
for (const part of parts2) {
|
|
66323
67600
|
const boxes = part.gone?.length ? subtract2(mergeSpans(part.spans), part.gone) : mergeSpans(part.spans);
|
|
66324
67601
|
for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
|
|
66325
|
-
const
|
|
66326
|
-
point.set(line.alongU ?
|
|
67602
|
+
const along22 = line.start + (s.a + s.b) / 2;
|
|
67603
|
+
point.set(line.alongU ? along22 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along22).applyMatrix4(toMesh);
|
|
66327
67604
|
const length2 = (s.b - s.a) / 2, up = (s.y1 - s.y0) / 2, across2 = part.thick / 2;
|
|
66328
67605
|
out.push({
|
|
66329
67606
|
center: [point.x, point.y, point.z],
|
|
@@ -66372,18 +67649,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66372
67649
|
if (list2) mesh3.userData.collapsedRanges = list2.filter((r) => r[0] !== v0);
|
|
66373
67650
|
withdrawSolids(mesh3, v0);
|
|
66374
67651
|
}
|
|
67652
|
+
var hash2 = (i, j) => {
|
|
67653
|
+
const s = Math.sin(i * 127.1 + j * 311.7) * 43758.5453;
|
|
67654
|
+
return s - Math.floor(s);
|
|
67655
|
+
};
|
|
66375
67656
|
function noise2(x, y, cell) {
|
|
66376
|
-
const h = (i2, j2) => {
|
|
66377
|
-
const s = Math.sin(i2 * 127.1 + j2 * 311.7) * 43758.5453;
|
|
66378
|
-
return s - Math.floor(s);
|
|
66379
|
-
};
|
|
66380
67657
|
const fx = x / cell, fy = y / cell, i = Math.floor(fx), j = Math.floor(fy), u = fx - i, v = fy - j;
|
|
66381
67658
|
const su = u * u * (3 - 2 * u), sv = v * v * (3 - 2 * v);
|
|
66382
|
-
return (
|
|
67659
|
+
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;
|
|
66383
67660
|
}
|
|
66384
67661
|
var MASK_TEXEL = 0.02;
|
|
66385
67662
|
var SPALL_MIN = 0.025;
|
|
66386
67663
|
var SPALL_RAGGED = 0.045;
|
|
67664
|
+
var PLASTER_REACH = { least: SPALL_MIN, band: SPALL_RAGGED };
|
|
66387
67665
|
var COVER2 = 0.015;
|
|
66388
67666
|
var LUMP_BAR_INSET = 0.035;
|
|
66389
67667
|
var LUMPS_PER_BAR = 1;
|
|
@@ -66799,13 +68077,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66799
68077
|
}
|
|
66800
68078
|
function splitUnits(view, id, around) {
|
|
66801
68079
|
const { mask } = view;
|
|
66802
|
-
const
|
|
68080
|
+
const along22 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
|
|
66803
68081
|
const part = structure.byId.get(id), units = specOf(id).units, chips2 = view.chips.get(id), opening = view.openings.get(id);
|
|
66804
68082
|
const own = cells(part, units, mask);
|
|
66805
68083
|
const all = (id === view.host ? own.flatMap((c) => besidePillars(c, around.pillars)) : own).flatMap((c) => outsideGaps(c, around.gaps));
|
|
66806
68084
|
const holes = [], kept = [];
|
|
66807
68085
|
if (view.fallen.has(id)) return { all, kept, holes: all, boxes: [] };
|
|
66808
|
-
const boxes = chips2.map((k) => ({ s0:
|
|
68086
|
+
const boxes = chips2.map((k) => ({ s0: along22(k.center) - k.along, s1: along22(k.center) + k.along, y0: k.center[1] - k.up, y1: k.center[1] + k.up }));
|
|
66809
68087
|
const gone = (c) => {
|
|
66810
68088
|
const over = boxes.filter((k) => k.s1 > c.a && k.s0 < c.b && k.y1 > c.y0 && k.y0 < c.y1);
|
|
66811
68089
|
const share = covered(c, over);
|
|
@@ -66813,7 +68091,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66813
68091
|
const s = (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2;
|
|
66814
68092
|
return share >= 0.5 && over.some((k) => s >= k.s0 && s <= k.s1 && y >= k.y0 && y <= k.y1);
|
|
66815
68093
|
};
|
|
66816
|
-
const open = (c) => gone(c) || opening !== void 0 && Math.hypot((c.a + c.b) / 2 -
|
|
68094
|
+
const open = (c) => gone(c) || opening !== void 0 && Math.hypot((c.a + c.b) / 2 - along22(opening.center), (c.y0 + c.y1) / 2 - opening.center[1]) < opening.radius;
|
|
66817
68095
|
for (const c of all) (open(c) ? holes : kept).push(c);
|
|
66818
68096
|
return { all, kept, holes, boxes };
|
|
66819
68097
|
}
|
|
@@ -66826,12 +68104,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66826
68104
|
function publishStanding(view) {
|
|
66827
68105
|
if (!view.saved) return;
|
|
66828
68106
|
const { mask } = view;
|
|
66829
|
-
const
|
|
68107
|
+
const along22 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
|
|
66830
68108
|
const parts2 = view.parts.map((id) => {
|
|
66831
68109
|
const part = structure.byId.get(id);
|
|
66832
68110
|
const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
|
|
66833
68111
|
const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
|
|
66834
|
-
const gone = (view.chips.get(id) ?? []).map((k) => ({ a:
|
|
68112
|
+
const gone = (view.chips.get(id) ?? []).map((k) => ({ a: along22(k.center) - k.along, b: along22(k.center) + k.along, y0: k.center[1] - k.up, y1: k.center[1] + k.up }));
|
|
66835
68113
|
return { spans: view.kept.get(id) ?? [], gone, thick, mid };
|
|
66836
68114
|
});
|
|
66837
68115
|
const line = { alongU: mask.alongU, start: mask.start, open: view.core };
|
|
@@ -66839,7 +68117,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66839
68117
|
}
|
|
66840
68118
|
function paint2(view) {
|
|
66841
68119
|
const { mask, core } = view;
|
|
66842
|
-
const
|
|
68120
|
+
const along22 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
|
|
66843
68121
|
const holes = [];
|
|
66844
68122
|
const pits = [];
|
|
66845
68123
|
const discs = [];
|
|
@@ -66857,8 +68135,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66857
68135
|
}
|
|
66858
68136
|
const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
|
|
66859
68137
|
const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
|
|
66860
|
-
if (opening) discs.push({ s:
|
|
66861
|
-
for (const k of spalls) flakes.push({ s:
|
|
68138
|
+
if (opening) discs.push({ s: along22(opening.center), y: opening.center[1], r: opening.radius });
|
|
68139
|
+
for (const k of spalls) flakes.push({ s: along22(k.center), y: k.center[1], r: k.radius });
|
|
66862
68140
|
holes.push(...lost);
|
|
66863
68141
|
view.kept.set(id, kept);
|
|
66864
68142
|
if (units2.mortar === part.material) {
|
|
@@ -66879,7 +68157,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66879
68157
|
mask.data.fill(0);
|
|
66880
68158
|
core.data.fill(0);
|
|
66881
68159
|
const stamp = (m, s0, s1, y0, y1, inside22) => stampMask(m, { s0, s1, y0, y1, reach: reach2 }, inside22);
|
|
66882
|
-
const
|
|
68160
|
+
const texel = { s: 0, y: 0 };
|
|
68161
|
+
const raggedAtTexel = () => ragged(texel.s, texel.y);
|
|
68162
|
+
const coreNoiseAtTexel = () => noise2(texel.s * 1.7, texel.y * 1.3, 0.012);
|
|
68163
|
+
const plaster = (d, s, y) => {
|
|
68164
|
+
texel.s = s;
|
|
68165
|
+
texel.y = y;
|
|
68166
|
+
return isPlasterGone(d, PLASTER_REACH, raggedAtTexel);
|
|
68167
|
+
};
|
|
68168
|
+
const coreThrough = (distance4, depth, s, y) => {
|
|
68169
|
+
texel.s = s;
|
|
68170
|
+
texel.y = y;
|
|
68171
|
+
return isCoreThrough(distance4, depth, coreNoiseAtTexel);
|
|
68172
|
+
};
|
|
66883
68173
|
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));
|
|
66884
68174
|
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));
|
|
66885
68175
|
for (const f of flakes) {
|
|
@@ -66888,7 +68178,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66888
68178
|
}
|
|
66889
68179
|
for (const p of pits) {
|
|
66890
68180
|
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));
|
|
66891
|
-
stamp(core, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) =>
|
|
68181
|
+
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));
|
|
66892
68182
|
}
|
|
66893
68183
|
for (const q of pillars) {
|
|
66894
68184
|
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));
|
|
@@ -67632,7 +68922,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67632
68922
|
const left = breach.standing(part.id);
|
|
67633
68923
|
if (!left) return true;
|
|
67634
68924
|
const s0 = (left.alongU ? lx : lz) - left.start;
|
|
67635
|
-
|
|
68925
|
+
const low1 = Math.min(ly0, ly1), high1 = Math.max(ly0, ly1);
|
|
68926
|
+
for (const c of left.spans) if (c.b > s0 - radius && c.a < s0 + radius && c.y1 > low1 && c.y0 < high1) return true;
|
|
67636
68927
|
}
|
|
67637
68928
|
return false;
|
|
67638
68929
|
};
|
|
@@ -68350,8 +69641,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68350
69641
|
const ends = rr.alongX ? [[rr.gable ? x0 + EDGE2 : x0 + rr.rm, ridgeY, zm], [rr.gable ? x1 - EDGE2 : x1 - rr.rm, ridgeY, zm]] : [[xm, ridgeY, rr.gable ? z0 + EDGE2 : z0 + rr.rm], [xm, ridgeY, rr.gable ? z1 - EDGE2 : z1 - rr.rm]];
|
|
68351
69642
|
const ridgeTop = TIMBER.purlin.top;
|
|
68352
69643
|
addTimberAround(timber, down(ends[0], ridgeTop), down(ends[1], ridgeTop), TIMBER.purlin.width, TIMBER.purlin.height, "purlin", keepOut, (end3) => addPost(timber, end3[0], end3[2], slabTop, end3[1] - TIMBER.purlin.height));
|
|
68353
|
-
const
|
|
68354
|
-
const posts = Math.max(1, Math.ceil(
|
|
69644
|
+
const along22 = Math.hypot(ends[1][0] - ends[0][0], ends[1][2] - ends[0][2]);
|
|
69645
|
+
const posts = Math.max(1, Math.ceil(along22 / TIMBER.post.spacing));
|
|
68355
69646
|
for (let j = 0; j <= posts; j++) {
|
|
68356
69647
|
const f = posts ? j / posts : 0;
|
|
68357
69648
|
const x = ends[0][0] + (ends[1][0] - ends[0][0]) * f, z = ends[0][2] + (ends[1][2] - ends[0][2]) * f;
|
|
@@ -69258,7 +70549,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69258
70549
|
var HOLD_REACH2 = 0.05;
|
|
69259
70550
|
var BACK_TOUCH = 0.02;
|
|
69260
70551
|
var AGAINST_WALL = 0.1;
|
|
69261
|
-
var
|
|
70552
|
+
var SOFT2 = /* @__PURE__ */ new Set(["fabric", "paper", "foliage"]);
|
|
69262
70553
|
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])));
|
|
69263
70554
|
function groupsOf(parts2, joints) {
|
|
69264
70555
|
const root = new Map(parts2.map((part) => [part.id, part.id]));
|
|
@@ -69329,7 +70620,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69329
70620
|
continue;
|
|
69330
70621
|
}
|
|
69331
70622
|
const againstWall = held.length === 0 || held.some((part) => boxOf4(part.id).min[2] <= back2 + AGAINST_WALL);
|
|
69332
|
-
const onWall = againstWall ? group.filter((part) => !
|
|
70623
|
+
const onWall = againstWall ? group.filter((part) => !SOFT2.has(part.material) && boxOf4(part.id).min[2] <= back2 + BACK_TOUCH) : [];
|
|
69333
70624
|
if (onWall.length === 0) continue;
|
|
69334
70625
|
for (const part of onWall) part.anchored = true;
|
|
69335
70626
|
changed = true;
|
|
@@ -76762,9 +78053,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
76762
78053
|
};
|
|
76763
78054
|
var fitLength = (kit, inner, lengthMetres) => {
|
|
76764
78055
|
const box5 = new kit.THREE.Box3().setFromObject(inner);
|
|
76765
|
-
const
|
|
76766
|
-
inner.scale.x =
|
|
76767
|
-
inner.position.x = -box5.min.x *
|
|
78056
|
+
const factor2 = lengthMetres / (box5.max.x - box5.min.x);
|
|
78057
|
+
inner.scale.x = factor2;
|
|
78058
|
+
inner.position.x = -box5.min.x * factor2;
|
|
76768
78059
|
const root = kit.group();
|
|
76769
78060
|
root.add(inner);
|
|
76770
78061
|
return root;
|
|
@@ -83551,9 +84842,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
83551
84842
|
} else hip.set(side * NO_GRIP_REAR[0], NO_GRIP_REAR[1], NO_GRIP_REAR[2] + box5.min.x);
|
|
83552
84843
|
const k = ease(Math.max(0, Math.min(1, placement.aim)));
|
|
83553
84844
|
if (k > 0) {
|
|
83554
|
-
const
|
|
84845
|
+
const along3 = box5.min.x + hold.sights.fromRear;
|
|
83555
84846
|
scratch2.aimed ?? (scratch2.aimed = new THREE.Vector3());
|
|
83556
|
-
hip.lerp(scratch2.aimed.set(0, -SIGHT_UNDER_EYE - box5.max.y,
|
|
84847
|
+
hip.lerp(scratch2.aimed.set(0, -SIGHT_UNDER_EYE - box5.max.y, along3 - hold.sights.distance), k);
|
|
83557
84848
|
}
|
|
83558
84849
|
holder.position.copy(hip).add(placement.offset);
|
|
83559
84850
|
hand.updateMatrixWorld(true);
|
|
@@ -86947,8 +88238,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
86947
88238
|
const end3 = CURVE[CURVE.length - 1];
|
|
86948
88239
|
const before = CURVE[CURVE.length - 2];
|
|
86949
88240
|
const angle = Math.atan2(end3[1] - before[1], end3[0] - before[0]);
|
|
86950
|
-
const
|
|
86951
|
-
const prongs = [-1, 1].map((side) => mesh3(bx(0.1, 0.016, 0.022), steel, [...
|
|
88241
|
+
const along3 = (distance4) => [end3[0] + Math.cos(angle) * distance4, end3[1] + Math.sin(angle) * distance4, 0];
|
|
88242
|
+
const prongs = [-1, 1].map((side) => mesh3(bx(0.1, 0.016, 0.022), steel, [...along3(0.03)].map((value, index) => index === 2 ? side * 0.014 : value), [0, 0, angle]));
|
|
86952
88243
|
const { bar: bar2, chisel } = shapesOf(T2, extrude2);
|
|
86953
88244
|
return G(mesh3(bar2, forged), mesh3(chisel, steel), ...prongs);
|
|
86954
88245
|
};
|
|
@@ -87678,15 +88969,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
87678
88969
|
return G(lower, stripe, upper, topCrimp, bottomCrimp, label, drop);
|
|
87679
88970
|
};
|
|
87680
88971
|
var syringe = ({ mesh: mesh3, bx, cyl, G, plastic, metal: metal2, glass }) => {
|
|
87681
|
-
const
|
|
88972
|
+
const along3 = [0, 0, Math.PI / 2];
|
|
87682
88973
|
const alongTip = [0, 0, -Math.PI / 2];
|
|
87683
|
-
const barrel = mesh3(cyl(0.075, 0.075, 0.7, 10), glass(13625584, 0.55), [-0.1, 0, 0],
|
|
87684
|
-
const flange = mesh3(cyl(0.1, 0.1, 0.025, 12), plastic(15265520), [-0.45, 0, 0],
|
|
87685
|
-
const stopper = mesh3(cyl(0.07, 0.07, 0.07, 8), plastic(2829099), [-0.3, 0, 0],
|
|
87686
|
-
const rod = mesh3(cyl(0.022, 0.022, 0.5, 6), plastic(15265520), [-0.475, 0, 0],
|
|
87687
|
-
const thumbRest = mesh3(cyl(0.09, 0.09, 0.025, 10), plastic(15265520), [-0.7375, 0, 0],
|
|
88974
|
+
const barrel = mesh3(cyl(0.075, 0.075, 0.7, 10), glass(13625584, 0.55), [-0.1, 0, 0], along3);
|
|
88975
|
+
const flange = mesh3(cyl(0.1, 0.1, 0.025, 12), plastic(15265520), [-0.45, 0, 0], along3);
|
|
88976
|
+
const stopper = mesh3(cyl(0.07, 0.07, 0.07, 8), plastic(2829099), [-0.3, 0, 0], along3);
|
|
88977
|
+
const rod = mesh3(cyl(0.022, 0.022, 0.5, 6), plastic(15265520), [-0.475, 0, 0], along3);
|
|
88978
|
+
const thumbRest = mesh3(cyl(0.09, 0.09, 0.025, 10), plastic(15265520), [-0.7375, 0, 0], along3);
|
|
87688
88979
|
const hub = mesh3(cyl(0.025, 0.06, 0.1, 8), plastic(15790320), [0.3, 0, 0], alongTip);
|
|
87689
|
-
const needle = mesh3(cyl(0.012, 0.012, 0.4, 6), metal2(13225683), [0.55, 0, 0],
|
|
88980
|
+
const needle = mesh3(cyl(0.012, 0.012, 0.4, 6), metal2(13225683), [0.55, 0, 0], along3);
|
|
87690
88981
|
const marks = [-0.3, -0.1, 0.1].map((x) => mesh3(bx(0.012, 0.15, 0.15), plastic(2781109), [x, 0, 0]));
|
|
87691
88982
|
return G(barrel, flange, stopper, rod, thumbRest, hub, needle, ...marks);
|
|
87692
88983
|
};
|
|
@@ -87721,13 +89012,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
87721
89012
|
return G(foam, core, strapLeft, strapRight);
|
|
87722
89013
|
};
|
|
87723
89014
|
var thermometer = ({ mesh: mesh3, bx, cyl, G, plastic, metal: metal2, glass }) => {
|
|
87724
|
-
const
|
|
89015
|
+
const along3 = [0, 0, -Math.PI / 2];
|
|
87725
89016
|
const body = mesh3(bx(0.8, 0.17, 0.3), plastic(15922421), [-0.2, -0.01, 0]);
|
|
87726
89017
|
const screen2 = mesh3(bx(0.34, 0.03, 0.16), glass(10471332, 0.9), [-0.3, 0.088, 0]);
|
|
87727
89018
|
const button = mesh3(cyl(0.05, 0.05, 0.03, 10), plastic(2788054), [0, 0.088, 0]);
|
|
87728
|
-
const collar = mesh3(cyl(0.07, 0.07, 0.04, 10), plastic(13949404), [0.22, 0, 0],
|
|
87729
|
-
const
|
|
87730
|
-
return G(body, screen2, button, collar,
|
|
89019
|
+
const collar = mesh3(cyl(0.07, 0.07, 0.04, 10), plastic(13949404), [0.22, 0, 0], along3);
|
|
89020
|
+
const probe2 = mesh3(cyl(0.04, 0.06, 0.36, 10), metal2(12041410), [0.42, 0, 0], along3);
|
|
89021
|
+
return G(body, screen2, button, collar, probe2);
|
|
87731
89022
|
};
|
|
87732
89023
|
var alcohol70 = ({ mesh: mesh3, cyl, lathe: lathe2, G, glass, plastic, paper: paper2 }) => {
|
|
87733
89024
|
const slim = [1, 1, 0.714];
|
|
@@ -90127,8 +91418,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
90127
91418
|
var hasItemModel = (id) => defaultItemModels().has(id);
|
|
90128
91419
|
var DEFAULT_COLOR = 9080724;
|
|
90129
91420
|
var PI13 = Math.PI;
|
|
90130
|
-
function shade2(color2,
|
|
90131
|
-
const channel = (shift) => Math.max(0, Math.min(255, Math.round((color2 >> shift & 255) *
|
|
91421
|
+
function shade2(color2, factor2) {
|
|
91422
|
+
const channel = (shift) => Math.max(0, Math.min(255, Math.round((color2 >> shift & 255) * factor2)));
|
|
90132
91423
|
return channel(16) << 16 | channel(8) << 8 | channel(0);
|
|
90133
91424
|
}
|
|
90134
91425
|
var PROUD = 2e-3;
|
|
@@ -90672,7 +91963,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
90672
91963
|
var MAX_CASINGS = 120;
|
|
90673
91964
|
var MAX_MAGAZINES = 12;
|
|
90674
91965
|
var LIFETIME_S = 25;
|
|
90675
|
-
var
|
|
91966
|
+
var GRAVITY3 = 9.81;
|
|
90676
91967
|
function createBoxFx(options) {
|
|
90677
91968
|
const { THREE, scene, camera: camera2, arsenal, groundAt } = options;
|
|
90678
91969
|
const audio = options.audio ?? null;
|
|
@@ -90843,7 +92134,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
90843
92134
|
const stepBody = (body, dt) => {
|
|
90844
92135
|
body.age += dt;
|
|
90845
92136
|
if (body.resting) return;
|
|
90846
|
-
body.velocity.y -=
|
|
92137
|
+
body.velocity.y -= GRAVITY3 * dt;
|
|
90847
92138
|
body.mesh.position.addScaledVector(body.velocity, dt);
|
|
90848
92139
|
body.mesh.rotation.x += body.spin.x * dt;
|
|
90849
92140
|
body.mesh.rotation.y += body.spin.y * dt;
|
|
@@ -90882,8 +92173,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
90882
92173
|
hand.updateMatrixWorld(true);
|
|
90883
92174
|
const at4 = model.localToWorld(v.copy(frontOf));
|
|
90884
92175
|
if (inLens) toWorldLens(camera2, at4, camera2.fov ?? 72, VIEW_HOLD.tool.fov);
|
|
90885
|
-
const
|
|
90886
|
-
return { position: [at4.x, at4.y, at4.z], direction: [
|
|
92176
|
+
const along3 = v2.set(1, 0, 0).applyQuaternion(model.getWorldQuaternion(q2)).normalize();
|
|
92177
|
+
return { position: [at4.x, at4.y, at4.z], direction: [along3.x, along3.y, along3.z], drawsFlash: false };
|
|
90887
92178
|
},
|
|
90888
92179
|
handTargets() {
|
|
90889
92180
|
const held = heldHold();
|
|
@@ -91701,7 +92992,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
91701
92992
|
const middle = fitted.integral === true ? -length2 / 2 : length2 / 2;
|
|
91702
92993
|
cylinderX(group, radius, length2, isImprovised ? M.rust : M.dark, middle, 0, 0, 18);
|
|
91703
92994
|
if (isImprovised) {
|
|
91704
|
-
for (const
|
|
92995
|
+
for (const along3 of [0.2, 0.8]) cylinderX(group, radius * 1.04, 0.012, M.tape, middle - length2 / 2 + length2 * along3, 0, 0, 18);
|
|
91705
92996
|
cylinderX(group, radius * 0.7, 8e-3, M.rustD, middle + length2 / 2 - 25e-4, 0, 0, 14);
|
|
91706
92997
|
} else {
|
|
91707
92998
|
for (let i = 0; i < BAFFLES; i++) cylinderX(group, radius * 1.03, 4e-3, M.metal, middle - length2 / 2 + length2 * (i + 0.5) / BAFFLES, 0, 0, 18);
|
|
@@ -93171,11 +94462,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93171
94462
|
this.spare.push(record);
|
|
93172
94463
|
}
|
|
93173
94464
|
/** Keeps the records `keep` accepts, in the same order, without allocating. `context` goes to `keep` so no closure is needed per frame. */
|
|
93174
|
-
compact(
|
|
94465
|
+
compact(keep2, context) {
|
|
93175
94466
|
let write = 0;
|
|
93176
94467
|
for (let read = 0; read < this.items.length; read++) {
|
|
93177
94468
|
const record = this.items[read];
|
|
93178
|
-
if (
|
|
94469
|
+
if (keep2(record, context)) {
|
|
93179
94470
|
this.items[write++] = record;
|
|
93180
94471
|
continue;
|
|
93181
94472
|
}
|
|
@@ -93425,8 +94716,70 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93425
94716
|
function streamFor3(eventSeed) {
|
|
93426
94717
|
return lehmer(mixEventSeed(eventSeed));
|
|
93427
94718
|
}
|
|
93428
|
-
var SKIN = 5e-3;
|
|
93429
94719
|
var MAX_PAD = 0.45;
|
|
94720
|
+
var SKIN = 5e-3;
|
|
94721
|
+
var Solids = class {
|
|
94722
|
+
constructor() {
|
|
94723
|
+
__publicField3(this, "queries", /* @__PURE__ */ new Map());
|
|
94724
|
+
__publicField3(this, "list", []);
|
|
94725
|
+
__publicField3(this, "hit", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
|
|
94726
|
+
}
|
|
94727
|
+
get empty() {
|
|
94728
|
+
return this.list.length === 0;
|
|
94729
|
+
}
|
|
94730
|
+
/** Declares or (with `null`) ends the solids `id` answers for. */
|
|
94731
|
+
set(id, query2) {
|
|
94732
|
+
if (query2) this.queries.set(id, query2);
|
|
94733
|
+
else this.queries.delete(id);
|
|
94734
|
+
this.list = [...this.queries.values()];
|
|
94735
|
+
}
|
|
94736
|
+
clear() {
|
|
94737
|
+
this.queries.clear();
|
|
94738
|
+
this.list = [];
|
|
94739
|
+
}
|
|
94740
|
+
/**
|
|
94741
|
+
* Stops a step that goes into a solid: `out` gets the nearest hit, put back the step's `pad` metres (at most `MAX_PAD`) off the surface (never behind where the step began) and
|
|
94742
|
+
* the surface's normal. Answers whether the step was stopped.
|
|
94743
|
+
*/
|
|
94744
|
+
stop(move2, out) {
|
|
94745
|
+
const dx = move2.x1 - move2.x0;
|
|
94746
|
+
const dy = move2.y1 - move2.y0;
|
|
94747
|
+
const dz = move2.z1 - move2.z0;
|
|
94748
|
+
const length2 = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
94749
|
+
if (!(length2 > 0)) return false;
|
|
94750
|
+
let nearest = Infinity;
|
|
94751
|
+
const list2 = this.list;
|
|
94752
|
+
for (let index = 0; index < list2.length; index++) {
|
|
94753
|
+
if (!list2[index](move2, this.hit)) continue;
|
|
94754
|
+
const reached = ((this.hit.x - move2.x0) * dx + (this.hit.y - move2.y0) * dy + (this.hit.z - move2.z0) * dz) / length2;
|
|
94755
|
+
if (reached >= nearest) continue;
|
|
94756
|
+
nearest = reached;
|
|
94757
|
+
out.x = this.hit.x;
|
|
94758
|
+
out.y = this.hit.y;
|
|
94759
|
+
out.z = this.hit.z;
|
|
94760
|
+
out.nx = this.hit.nx;
|
|
94761
|
+
out.ny = this.hit.ny;
|
|
94762
|
+
out.nz = this.hit.nz;
|
|
94763
|
+
}
|
|
94764
|
+
if (nearest === Infinity) return false;
|
|
94765
|
+
const hitX2 = out.x;
|
|
94766
|
+
const hitY2 = out.y;
|
|
94767
|
+
const hitZ = out.z;
|
|
94768
|
+
out.d = out.nx * hitX2 + out.ny * hitY2 + out.nz * hitZ;
|
|
94769
|
+
const back2 = Math.min(Math.min(Math.max(move2.pad, 0), MAX_PAD) + SKIN, Math.max(nearest, 0));
|
|
94770
|
+
out.x -= dx / length2 * back2;
|
|
94771
|
+
out.y -= dy / length2 * back2;
|
|
94772
|
+
out.z -= dz / length2 * back2;
|
|
94773
|
+
const off = (out.x - hitX2) * out.nx + (out.y - hitY2) * out.ny + (out.z - hitZ) * out.nz;
|
|
94774
|
+
if (off < SKIN) {
|
|
94775
|
+
out.x += out.nx * (SKIN - off);
|
|
94776
|
+
out.y += out.ny * (SKIN - off);
|
|
94777
|
+
out.z += out.nz * (SKIN - off);
|
|
94778
|
+
}
|
|
94779
|
+
return true;
|
|
94780
|
+
}
|
|
94781
|
+
};
|
|
94782
|
+
var SKIN2 = 5e-3;
|
|
93430
94783
|
function rotation(q) {
|
|
93431
94784
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
93432
94785
|
const n = Math.hypot(x, y, z, w) || 1;
|
|
@@ -93451,16 +94804,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93451
94804
|
__publicField3(this, "spaces", /* @__PURE__ */ new Map());
|
|
93452
94805
|
__publicField3(this, "list", []);
|
|
93453
94806
|
__publicField3(this, "random");
|
|
93454
|
-
__publicField3(this, "out", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
94807
|
+
__publicField3(this, "out", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
|
|
93455
94808
|
__publicField3(this, "l0", new Float64Array(3));
|
|
93456
94809
|
__publicField3(this, "l1", new Float64Array(3));
|
|
93457
94810
|
__publicField3(this, "q", new Float64Array(3));
|
|
93458
94811
|
__publicField3(this, "h", new Float64Array(3));
|
|
93459
94812
|
__publicField3(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
94813
|
+
__publicField3(this, "solids", new Solids());
|
|
93460
94814
|
this.random = lehmer(seed);
|
|
93461
94815
|
}
|
|
93462
94816
|
get empty() {
|
|
93463
|
-
return this.list.length === 0;
|
|
94817
|
+
return this.list.length === 0 && this.solids.empty;
|
|
94818
|
+
}
|
|
94819
|
+
/** 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. */
|
|
94820
|
+
solid(id, query2) {
|
|
94821
|
+
this.solids.set(id, query2);
|
|
93464
94822
|
}
|
|
93465
94823
|
get size() {
|
|
93466
94824
|
return this.list.length;
|
|
@@ -93521,7 +94879,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93521
94879
|
}
|
|
93522
94880
|
/** Passes at `rate` per second. */
|
|
93523
94881
|
chance(rate, dt) {
|
|
93524
|
-
return rate > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
|
|
94882
|
+
return rate > 0 && dt > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
|
|
93525
94883
|
}
|
|
93526
94884
|
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
93527
94885
|
through(s, q, dt) {
|
|
@@ -93543,6 +94901,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93543
94901
|
return this.confineMove(move2, dt);
|
|
93544
94902
|
}
|
|
93545
94903
|
confineMove(move2, dt) {
|
|
94904
|
+
if (this.confineSpaces(move2, dt)) return true;
|
|
94905
|
+
return !this.solids.empty && this.solids.stop(move2, this.out);
|
|
94906
|
+
}
|
|
94907
|
+
confineSpaces(move2, dt) {
|
|
93546
94908
|
const list2 = this.list;
|
|
93547
94909
|
if (list2.length === 0) return false;
|
|
93548
94910
|
const { x0, y0, z0, x1, y1, z1 } = move2;
|
|
@@ -93583,7 +94945,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93583
94945
|
}
|
|
93584
94946
|
}
|
|
93585
94947
|
sign2 = l1[axis2] < 0 ? -1 : 1;
|
|
93586
|
-
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] -
|
|
94948
|
+
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN2, Math.max(-(h[a] - SKIN2), l1[a]));
|
|
93587
94949
|
sign2 = -sign2;
|
|
93588
94950
|
} else {
|
|
93589
94951
|
const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
|
|
@@ -93600,7 +94962,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93600
94962
|
}
|
|
93601
94963
|
}
|
|
93602
94964
|
sign2 = l0[axis2] < 0 ? -1 : 1;
|
|
93603
|
-
l1[axis2] = sign2 * (h[axis2] + bound +
|
|
94965
|
+
l1[axis2] = sign2 * (h[axis2] + bound + SKIN2);
|
|
93604
94966
|
}
|
|
93605
94967
|
const r = s.r;
|
|
93606
94968
|
const out = this.out;
|
|
@@ -93610,6 +94972,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93610
94972
|
out.nx = r[axis2] * sign2;
|
|
93611
94973
|
out.ny = r[3 + axis2] * sign2;
|
|
93612
94974
|
out.nz = r[6 + axis2] * sign2;
|
|
94975
|
+
out.d = out.nx * s.cx + out.ny * s.cy + out.nz * s.cz + (in0 ? -h[axis2] : h[axis2]);
|
|
93613
94976
|
return true;
|
|
93614
94977
|
}
|
|
93615
94978
|
return false;
|
|
@@ -93627,6 +94990,127 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93627
94990
|
if (into >= 0) return [vx2, vy2, vz2];
|
|
93628
94991
|
return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
|
|
93629
94992
|
}
|
|
94993
|
+
var PUFF_REACH = 1.28;
|
|
94994
|
+
var PROBES = [{ x: 1, y: 0, z: 0 }, { x: -1, y: 0, z: 0 }, { x: 0, y: 0, z: 1 }, { x: 0, y: 0, z: -1 }, { x: 0, y: 1, z: 0 }];
|
|
94995
|
+
var PROBES_PER_SECOND = 60;
|
|
94996
|
+
var FRAMES_PER_PROBE = 3;
|
|
94997
|
+
var GROUND_FACING = 0.7;
|
|
94998
|
+
var SAME_WALL = 0.9;
|
|
94999
|
+
var PROBE = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
95000
|
+
var KeptCut = class {
|
|
95001
|
+
constructor() {
|
|
95002
|
+
__publicField3(this, "on", false);
|
|
95003
|
+
__publicField3(this, "nx", 0.5);
|
|
95004
|
+
__publicField3(this, "ny", 0.5);
|
|
95005
|
+
__publicField3(this, "nz", 0.5);
|
|
95006
|
+
__publicField3(this, "d", 0.5);
|
|
95007
|
+
}
|
|
95008
|
+
};
|
|
95009
|
+
function createCut() {
|
|
95010
|
+
return new KeptCut();
|
|
95011
|
+
}
|
|
95012
|
+
function clearCuts(puff3) {
|
|
95013
|
+
puff3.cuts[0].on = false;
|
|
95014
|
+
puff3.cuts[1].on = false;
|
|
95015
|
+
}
|
|
95016
|
+
var WrittenWay = class {
|
|
95017
|
+
constructor() {
|
|
95018
|
+
__publicField3(this, "x", 0.5);
|
|
95019
|
+
__publicField3(this, "y", 0.5);
|
|
95020
|
+
__publicField3(this, "z", 0.5);
|
|
95021
|
+
}
|
|
95022
|
+
};
|
|
95023
|
+
var WAY = new WrittenWay();
|
|
95024
|
+
function probe(confiner, puff3, way) {
|
|
95025
|
+
const reach2 = puff3.size * PUFF_REACH;
|
|
95026
|
+
if (!(reach2 > 0)) return false;
|
|
95027
|
+
PROBE.x0 = puff3.x;
|
|
95028
|
+
PROBE.y0 = puff3.y;
|
|
95029
|
+
PROBE.z0 = puff3.z;
|
|
95030
|
+
PROBE.x1 = puff3.x + way.x * reach2;
|
|
95031
|
+
PROBE.y1 = puff3.y + way.y * reach2;
|
|
95032
|
+
PROBE.z1 = puff3.z + way.z * reach2;
|
|
95033
|
+
PROBE.pad = 0;
|
|
95034
|
+
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
95035
|
+
}
|
|
95036
|
+
var isFartherFrom = (puff3, a, b) => a.nx * puff3.x + a.ny * puff3.y + a.nz * puff3.z - a.d > b.nx * puff3.x + b.ny * puff3.y + b.nz * puff3.z - b.d;
|
|
95037
|
+
var isBehind = (puff3, face) => face.nx * puff3.x + face.ny * puff3.y + face.nz * puff3.z < face.d;
|
|
95038
|
+
var sameWall = (cut, face) => cut.on && cut.nx * face.nx + cut.ny * face.ny + cut.nz * face.nz > SAME_WALL;
|
|
95039
|
+
function cutFor(puff3, face) {
|
|
95040
|
+
const first = puff3.cuts[0];
|
|
95041
|
+
const second = puff3.cuts[1];
|
|
95042
|
+
if (sameWall(first, face)) return first;
|
|
95043
|
+
if (sameWall(second, face)) return second;
|
|
95044
|
+
if (!first.on) return first;
|
|
95045
|
+
if (!second.on) return second;
|
|
95046
|
+
const farther = isFartherFrom(puff3, first, second) ? first : second;
|
|
95047
|
+
return isFartherFrom(puff3, farther, face) ? farther : void 0;
|
|
95048
|
+
}
|
|
95049
|
+
function cutAtFace(puff3, face) {
|
|
95050
|
+
if (face.ny > GROUND_FACING) return;
|
|
95051
|
+
const cut = cutFor(puff3, face);
|
|
95052
|
+
if (!cut) return;
|
|
95053
|
+
cut.on = true;
|
|
95054
|
+
cut.nx = face.nx;
|
|
95055
|
+
cut.ny = face.ny;
|
|
95056
|
+
cut.nz = face.nz;
|
|
95057
|
+
cut.d = face.d;
|
|
95058
|
+
}
|
|
95059
|
+
function cutFrom(puff3, out) {
|
|
95060
|
+
cutAtFace(puff3, out);
|
|
95061
|
+
}
|
|
95062
|
+
function cutAt2(confiner, puff3, way) {
|
|
95063
|
+
if (!probe(confiner, puff3, way)) return false;
|
|
95064
|
+
cutAtFace(puff3, confiner.out);
|
|
95065
|
+
return true;
|
|
95066
|
+
}
|
|
95067
|
+
function backward(puff3) {
|
|
95068
|
+
const speed = Math.sqrt(puff3.vx * puff3.vx + puff3.vy * puff3.vy + puff3.vz * puff3.vz);
|
|
95069
|
+
if (!(speed > 0)) return null;
|
|
95070
|
+
WAY.x = -puff3.vx / speed;
|
|
95071
|
+
WAY.y = -puff3.vy / speed;
|
|
95072
|
+
WAY.z = -puff3.vz / speed;
|
|
95073
|
+
return WAY;
|
|
95074
|
+
}
|
|
95075
|
+
function along2(cut, sign2) {
|
|
95076
|
+
WAY.x = sign2 * cut.nx;
|
|
95077
|
+
WAY.y = sign2 * cut.ny;
|
|
95078
|
+
WAY.z = sign2 * cut.nz;
|
|
95079
|
+
return WAY;
|
|
95080
|
+
}
|
|
95081
|
+
function dropPassed(confiner, puff3) {
|
|
95082
|
+
for (let i = 0; i < 2; i++) {
|
|
95083
|
+
const cut = puff3.cuts[i];
|
|
95084
|
+
if (!cut.on || !isBehind(puff3, cut)) continue;
|
|
95085
|
+
cut.on = false;
|
|
95086
|
+
cutAt2(confiner, puff3, along2(cut, 1));
|
|
95087
|
+
}
|
|
95088
|
+
}
|
|
95089
|
+
function keep(confiner, puff3, cut) {
|
|
95090
|
+
if (!cut.on) return;
|
|
95091
|
+
if (!probe(confiner, puff3, along2(cut, -1))) {
|
|
95092
|
+
cut.on = false;
|
|
95093
|
+
return;
|
|
95094
|
+
}
|
|
95095
|
+
cut.d = confiner.out.d;
|
|
95096
|
+
}
|
|
95097
|
+
function lookForWalls(confiner, puff3) {
|
|
95098
|
+
dropPassed(confiner, puff3);
|
|
95099
|
+
const turn2 = Math.round(puff3.t * PROBES_PER_SECOND);
|
|
95100
|
+
if (turn2 <= 1) {
|
|
95101
|
+
const back2 = backward(puff3);
|
|
95102
|
+
if (back2) cutAt2(confiner, puff3, back2);
|
|
95103
|
+
for (let i = 0; i < PROBES.length; i++) cutAt2(confiner, puff3, PROBES[i]);
|
|
95104
|
+
return;
|
|
95105
|
+
}
|
|
95106
|
+
if (turn2 % FRAMES_PER_PROBE !== 0) return;
|
|
95107
|
+
const slot = turn2 / FRAMES_PER_PROBE % (PROBES.length + 3);
|
|
95108
|
+
if (slot < 2) keep(confiner, puff3, puff3.cuts[slot]);
|
|
95109
|
+
else if (slot === 2) {
|
|
95110
|
+
const back2 = backward(puff3);
|
|
95111
|
+
if (back2) cutAt2(confiner, puff3, back2);
|
|
95112
|
+
} else cutAt2(confiner, puff3, PROBES[slot - 3]);
|
|
95113
|
+
}
|
|
93630
95114
|
var FLOOR_FRACTION = 0.4;
|
|
93631
95115
|
var FLOOR_BOUNCE = -0.2;
|
|
93632
95116
|
var ARRIVAL_FRAME = 30;
|
|
@@ -93666,7 +95150,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93666
95150
|
age: 0,
|
|
93667
95151
|
heat: 0,
|
|
93668
95152
|
size: 0,
|
|
93669
|
-
source: void 0
|
|
95153
|
+
source: void 0,
|
|
95154
|
+
cuts: [createCut(), createCut()]
|
|
93670
95155
|
}));
|
|
93671
95156
|
}
|
|
93672
95157
|
function spawnPuff(pool, random, init) {
|
|
@@ -93700,6 +95185,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93700
95185
|
puff3.heat = 0;
|
|
93701
95186
|
puff3.size = 0;
|
|
93702
95187
|
puff3.source = init.source;
|
|
95188
|
+
clearCuts(puff3);
|
|
93703
95189
|
return puff3;
|
|
93704
95190
|
}
|
|
93705
95191
|
function ageOrKeep2(puff3, dt) {
|
|
@@ -93749,17 +95235,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93749
95235
|
MOVE.z0 = puff3.z;
|
|
93750
95236
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
93751
95237
|
else moveFree(puff3, dt, age, heat, wind);
|
|
93752
|
-
|
|
95238
|
+
const carried = confining && CARRIED_KINDS[puff3.kind];
|
|
95239
|
+
if (carried && confine(confiner, puff3, dt)) {
|
|
93753
95240
|
const out = confiner.out;
|
|
93754
95241
|
puff3.x = out.x;
|
|
93755
95242
|
puff3.y = out.y;
|
|
93756
95243
|
puff3.z = out.z;
|
|
93757
95244
|
slideInto(out, puff3);
|
|
95245
|
+
cutFrom(puff3, out);
|
|
93758
95246
|
}
|
|
93759
95247
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
93760
95248
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
93761
95249
|
puff3.age = age;
|
|
93762
95250
|
puff3.heat = heat;
|
|
95251
|
+
if (carried) lookForWalls(confiner, puff3);
|
|
95252
|
+
else clearCuts(puff3);
|
|
93763
95253
|
}
|
|
93764
95254
|
}
|
|
93765
95255
|
var GROUND_LIFT = 0.02;
|
|
@@ -94483,7 +95973,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94483
95973
|
var BODY_Z2 = BODIES.map(([, z]) => z);
|
|
94484
95974
|
var FACING = BODIES.map(([x, z]) => Math.atan2(-x, -z));
|
|
94485
95975
|
var FUSE = 1.8;
|
|
94486
|
-
var
|
|
95976
|
+
var GRAVITY4 = 9.8;
|
|
94487
95977
|
var FLOOR = 0.07;
|
|
94488
95978
|
var BOUNCE = -0.4;
|
|
94489
95979
|
var SIDE_LOSS = 0.5;
|
|
@@ -94513,7 +96003,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94513
96003
|
],
|
|
94514
96004
|
tick: [
|
|
94515
96005
|
when(lt(TIME, FUSE), [
|
|
94516
|
-
set("vy", sub(variable("vy"), mul(
|
|
96006
|
+
set("vy", sub(variable("vy"), mul(GRAVITY4, DELTA))),
|
|
94517
96007
|
set("px", add(variable("px"), mul(variable("vx"), DELTA))),
|
|
94518
96008
|
set("py", add(variable("py"), mul(variable("vy"), DELTA))),
|
|
94519
96009
|
set("pz", add(variable("pz"), mul(variable("vz"), DELTA))),
|
|
@@ -94655,11 +96145,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94655
96145
|
function plus(vector2, x, y, z) {
|
|
94656
96146
|
return [vector2[0] + x, vector2[1] + y, vector2[2] + z];
|
|
94657
96147
|
}
|
|
94658
|
-
function scaledBy(vector2,
|
|
94659
|
-
return [vector2[0] *
|
|
96148
|
+
function scaledBy(vector2, factor2) {
|
|
96149
|
+
return [vector2[0] * factor2, vector2[1] * factor2, vector2[2] * factor2];
|
|
94660
96150
|
}
|
|
94661
|
-
function plusScaled(vector2, direction,
|
|
94662
|
-
return [vector2[0] + direction[0] *
|
|
96151
|
+
function plusScaled(vector2, direction, factor2) {
|
|
96152
|
+
return [vector2[0] + direction[0] * factor2, vector2[1] + direction[1] * factor2, vector2[2] + direction[2] * factor2];
|
|
94663
96153
|
}
|
|
94664
96154
|
function negated(vector2) {
|
|
94665
96155
|
return [-vector2[0], -vector2[1], -vector2[2]];
|
|
@@ -95690,7 +97180,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
95690
97180
|
var ORIGIN = [0, 0, 0];
|
|
95691
97181
|
var FACING4 = [0, 0, 1];
|
|
95692
97182
|
var UP11 = [0, 1, 0];
|
|
95693
|
-
var grow = (piece3,
|
|
97183
|
+
var grow = (piece3, factor2) => [piece3[0] * factor2, piece3[1] * factor2, piece3[2] * factor2];
|
|
95694
97184
|
var debrisTone = (look) => or(variable(DEBRIS_COLOR_VARIABLE), look.debris);
|
|
95695
97185
|
var dustTone = (look) => or(variable(DUST_COLOR_VARIABLE), look.dust);
|
|
95696
97186
|
var sparks = (look, count) => look.sparks ? [call2("spark_at", ORIGIN, FACING4, count, 0.9)] : [];
|
|
@@ -96730,10 +98220,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96730
98220
|
var MAX_SCALE = 3;
|
|
96731
98221
|
var MIN_SCALE = 0.6;
|
|
96732
98222
|
function reflected(direction, normal) {
|
|
96733
|
-
const
|
|
96734
|
-
const out = [direction[0] - 2 *
|
|
98223
|
+
const along22 = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
|
|
98224
|
+
const out = [direction[0] - 2 * along22 * normal[0], direction[1] - 2 * along22 * normal[1], direction[2] - 2 * along22 * normal[2]];
|
|
96735
98225
|
const length2 = Math.hypot(out[0], out[1], out[2]);
|
|
96736
|
-
if (length2 < 1e-6 || Math.abs(
|
|
98226
|
+
if (length2 < 1e-6 || Math.abs(along22) > 0.98) return normal;
|
|
96737
98227
|
return [out[0] / length2, out[1] / length2, out[2] / length2];
|
|
96738
98228
|
}
|
|
96739
98229
|
var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
|
|
@@ -96766,13 +98256,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96766
98256
|
var UP12 = [0, 1, 0];
|
|
96767
98257
|
var ZERO2 = [0, 0, 0];
|
|
96768
98258
|
var FULL_TURN_DRAWN = 6.283;
|
|
96769
|
-
function scaledSizes(range22,
|
|
96770
|
-
return [range22[0] * Math.sqrt(
|
|
98259
|
+
function scaledSizes(range22, factor2) {
|
|
98260
|
+
return [range22[0] * Math.sqrt(factor2), range22[1] * Math.sqrt(factor2)];
|
|
96771
98261
|
}
|
|
96772
|
-
function fireEmit(engine, key2, dt, centre, radius,
|
|
98262
|
+
function fireEmit(engine, key2, dt, centre, radius, factor2, options = {}) {
|
|
96773
98263
|
const wind = options.wind ?? ZERO2;
|
|
96774
|
-
const sqrtFactor = Math.sqrt(
|
|
96775
|
-
engine.emit(`${key2}f`, "add", 90 *
|
|
98264
|
+
const sqrtFactor = Math.sqrt(factor2);
|
|
98265
|
+
engine.emit(`${key2}f`, "add", 90 * factor2, dt, () => ({
|
|
96776
98266
|
p: centre,
|
|
96777
98267
|
r: radius,
|
|
96778
98268
|
flat: true,
|
|
@@ -96781,7 +98271,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96781
98271
|
sp: [0.4, 1.4],
|
|
96782
98272
|
v: wind,
|
|
96783
98273
|
life: [0.35, 0.85],
|
|
96784
|
-
size: scaledSizes([0.22, 0.5],
|
|
98274
|
+
size: scaledSizes([0.22, 0.5], factor2),
|
|
96785
98275
|
grow: 0.35,
|
|
96786
98276
|
c0: 16765562,
|
|
96787
98277
|
c1: 9050629,
|
|
@@ -96789,7 +98279,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96789
98279
|
fi: 0.15,
|
|
96790
98280
|
g: -2.2
|
|
96791
98281
|
}));
|
|
96792
|
-
engine.emit(`${key2}c`, "add", 30 *
|
|
98282
|
+
engine.emit(`${key2}c`, "add", 30 * factor2, dt, () => ({
|
|
96793
98283
|
p: centre,
|
|
96794
98284
|
r: radius * 0.6,
|
|
96795
98285
|
flat: true,
|
|
@@ -96797,7 +98287,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96797
98287
|
cone: 0.3,
|
|
96798
98288
|
sp: [0.3, 0.8],
|
|
96799
98289
|
life: [0.2, 0.4],
|
|
96800
|
-
size: scaledSizes([0.25, 0.4],
|
|
98290
|
+
size: scaledSizes([0.25, 0.4], factor2),
|
|
96801
98291
|
grow: 0.6,
|
|
96802
98292
|
c0: 16773824,
|
|
96803
98293
|
c1: 16747040,
|
|
@@ -96806,13 +98296,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96806
98296
|
g: -1
|
|
96807
98297
|
}));
|
|
96808
98298
|
if (engine.quality < 2) {
|
|
96809
|
-
engine.emit(`${key2}e`, "streak", 10 *
|
|
98299
|
+
engine.emit(`${key2}e`, "streak", 10 * factor2, dt, () => {
|
|
96810
98300
|
const jitter = plus(wind, engine.random.between(-0.4, 0.4), 0, engine.random.between(-0.4, 0.4));
|
|
96811
98301
|
return { p: centre, box: [radius, 0, radius], dir: UP12, cone: 0.5, sp: [1.5, 3.5], v: jitter, life: [0.8, 1.8], len: 0.03, c0: 16756816, c1: 6295552, g: -0.6, drag: 0.4 };
|
|
96812
98302
|
});
|
|
96813
98303
|
}
|
|
96814
98304
|
if (options.noSmoke) return;
|
|
96815
|
-
engine.emit(`${key2}s`, "normal", (options.smoke || 14) *
|
|
98305
|
+
engine.emit(`${key2}s`, "normal", (options.smoke || 14) * factor2, dt, () => ({
|
|
96816
98306
|
p: plus(centre, 0, 0.8 * sqrtFactor, 0),
|
|
96817
98307
|
r: radius * 0.7,
|
|
96818
98308
|
dir: UP12,
|
|
@@ -96821,7 +98311,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96821
98311
|
v: wind,
|
|
96822
98312
|
drag: 0.15,
|
|
96823
98313
|
life: [2.5, 4.5],
|
|
96824
|
-
size: scaledSizes([0.4, 0.8],
|
|
98314
|
+
size: scaledSizes([0.4, 0.8], factor2),
|
|
96825
98315
|
grow: 4,
|
|
96826
98316
|
c0: options.smokeColor || 2762018,
|
|
96827
98317
|
c1: 1184536,
|
|
@@ -96906,7 +98396,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96906
98396
|
var MACROS = {
|
|
96907
98397
|
blood_hit: ({ engine }, [point, direction, age, scale]) => bloodHit(engine, point, direction, age, scale),
|
|
96908
98398
|
impact: ({ engine }, [material, point, normal, scale, age]) => impact2(engine, material, point, normal, scale, age),
|
|
96909
|
-
fire_emit: ({ engine, dt }, [key2, centre, radius,
|
|
98399
|
+
fire_emit: ({ engine, dt }, [key2, centre, radius, factor2, options]) => fireEmit(engine, key2, dt, centre, radius, factor2, options),
|
|
96910
98400
|
explode: ({ engine, cameraPosition }, [point, scale, chipColor]) => explode(engine, point, scale, cameraPosition, chipColor),
|
|
96911
98401
|
muzzle: ({ engine }, [weapon2, tip, direction]) => muzzle(engine, weapon2, tip, direction),
|
|
96912
98402
|
casing: ({ engine }, [port, type]) => casing(engine, port, type),
|
|
@@ -97587,6 +99077,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97587
99077
|
screen2.flashDecay = 0.5;
|
|
97588
99078
|
}
|
|
97589
99079
|
}
|
|
99080
|
+
var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
99081
|
+
function bornFrom(core, puff3, ox, oy, oz) {
|
|
99082
|
+
const confiner = core.confiner;
|
|
99083
|
+
if (confiner.empty) return;
|
|
99084
|
+
BIRTH.x0 = ox;
|
|
99085
|
+
BIRTH.y0 = oy;
|
|
99086
|
+
BIRTH.z0 = oz;
|
|
99087
|
+
BIRTH.x1 = puff3.x;
|
|
99088
|
+
BIRTH.y1 = puff3.y;
|
|
99089
|
+
BIRTH.z1 = puff3.z;
|
|
99090
|
+
BIRTH.pad = puff3.s0 * PAD_OF_SIZE;
|
|
99091
|
+
if (!confiner.confineMove(BIRTH, 0)) return;
|
|
99092
|
+
const out = confiner.out;
|
|
99093
|
+
puff3.x = out.x;
|
|
99094
|
+
puff3.y = out.y;
|
|
99095
|
+
puff3.z = out.z;
|
|
99096
|
+
slideInto(out, puff3);
|
|
99097
|
+
}
|
|
97590
99098
|
function composeFireballs(context) {
|
|
97591
99099
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
97592
99100
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -97603,7 +99111,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97603
99111
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life);
|
|
97604
99112
|
const h0 = random.between(1.05, 1.35) * heat;
|
|
97605
99113
|
const hl = fuel ? random.between(0.8, 1.4) * (def.heatLifeScale ?? 1) : random.between(0.22, 0.42);
|
|
97606
|
-
addPuff(core, random, {
|
|
99114
|
+
const fireball = addPuff(core, random, {
|
|
97607
99115
|
x: x + d.x * size * 0.15,
|
|
97608
99116
|
y: y + size * 0.25 + d.y * size * 0.1,
|
|
97609
99117
|
z: z + d.z * size * 0.15,
|
|
@@ -97622,6 +99130,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97622
99130
|
color: context.smokeColor,
|
|
97623
99131
|
kind: 0
|
|
97624
99132
|
});
|
|
99133
|
+
bornFrom(core, fireball, x, y, z);
|
|
97625
99134
|
}
|
|
97626
99135
|
}
|
|
97627
99136
|
function composeSmoke(context) {
|
|
@@ -97635,7 +99144,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97635
99144
|
const s1 = size * random.between(0.55, 0.85);
|
|
97636
99145
|
const sg = size * random.between(0.18, 0.3);
|
|
97637
99146
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life * 1.1);
|
|
97638
|
-
addPuff(core, random, {
|
|
99147
|
+
const smoke = addPuff(core, random, {
|
|
97639
99148
|
x: x + d.x * size * 0.6,
|
|
97640
99149
|
y: y + size * 0.4 + d.y * size * 0.5,
|
|
97641
99150
|
z: z + d.z * size * 0.6,
|
|
@@ -97654,6 +99163,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97654
99163
|
color: context.smokeColor,
|
|
97655
99164
|
kind: def.smoke.kind ?? 0
|
|
97656
99165
|
});
|
|
99166
|
+
bornFrom(core, smoke, x, y, z);
|
|
97657
99167
|
}
|
|
97658
99168
|
}
|
|
97659
99169
|
function composeShock(context) {
|
|
@@ -97665,7 +99175,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97665
99175
|
spawnShock(core.shocks, spec);
|
|
97666
99176
|
}
|
|
97667
99177
|
function composeDust(context) {
|
|
97668
|
-
const { core, def, random, x, z, size, scale } = context;
|
|
99178
|
+
const { core, def, random, x, y, z, size, scale } = context;
|
|
97669
99179
|
if (!core.layers.smoke || !def.dust.count || !(scale > 0.15)) return;
|
|
97670
99180
|
const count = Math.round(def.dust.count * scale);
|
|
97671
99181
|
const color2 = hexToLinearRgb(def.dust.color);
|
|
@@ -97678,7 +99188,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97678
99188
|
const s1 = size * random.between(0.5, 0.8);
|
|
97679
99189
|
const sg = size * random.between(0.2, 0.35);
|
|
97680
99190
|
const life = random.between(2.2, 4);
|
|
97681
|
-
addPuff(core, random, {
|
|
99191
|
+
const dust = addPuff(core, random, {
|
|
97682
99192
|
x: x + Math.cos(angle) * 0.3,
|
|
97683
99193
|
y: 0.15,
|
|
97684
99194
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -97695,6 +99205,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97695
99205
|
color: color2,
|
|
97696
99206
|
kind: 1
|
|
97697
99207
|
});
|
|
99208
|
+
bornFrom(core, dust, x, y, z);
|
|
97698
99209
|
}
|
|
97699
99210
|
}
|
|
97700
99211
|
function coneAngle(context) {
|
|
@@ -98025,6 +99536,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98025
99536
|
state.beat *= Math.exp(-DECAY.beat * dt);
|
|
98026
99537
|
}
|
|
98027
99538
|
var PAD_OF_SIZE2 = 0.35;
|
|
99539
|
+
var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
99540
|
+
var GROUND_RESAMPLE = 0.1;
|
|
99541
|
+
var VELOCITY2 = { vx: 0.5, vy: 0.5, vz: 0.5 };
|
|
98028
99542
|
var clamp42 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
98029
99543
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
98030
99544
|
function rgb(hex2) {
|
|
@@ -98071,6 +99585,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98071
99585
|
__publicField3(this, "bounced");
|
|
98072
99586
|
__publicField3(this, "floor");
|
|
98073
99587
|
__publicField3(this, "riseMul");
|
|
99588
|
+
__publicField3(this, "ground");
|
|
98074
99589
|
const n = Math.max(1, capacity);
|
|
98075
99590
|
this.position = new Float32Array(n * 3);
|
|
98076
99591
|
this.color = new Float32Array(n * 3);
|
|
@@ -98093,6 +99608,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98093
99608
|
this.bounced = new Uint8Array(n);
|
|
98094
99609
|
this.floor = new Float32Array(n);
|
|
98095
99610
|
this.riseMul = new Float32Array(n);
|
|
99611
|
+
this.ground = new Float32Array(n * 3);
|
|
98096
99612
|
}
|
|
98097
99613
|
spawn(kind, p, v, random, options) {
|
|
98098
99614
|
if (this.capacity <= 0) return;
|
|
@@ -98120,6 +99636,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98120
99636
|
this.bounced[i] = 0;
|
|
98121
99637
|
this.floor[i] = options?.floor ?? Number.NaN;
|
|
98122
99638
|
this.riseMul[i] = options?.rise ?? 1;
|
|
99639
|
+
this.ground[i * 3] = Number.NaN;
|
|
98123
99640
|
this.size[i] = this.size0[i];
|
|
98124
99641
|
this.alpha[i] = 0;
|
|
98125
99642
|
}
|
|
@@ -98213,18 +99730,36 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98213
99730
|
let z = this.position[i3 + 2] + vz2 * dt;
|
|
98214
99731
|
const confiner = host.confiner;
|
|
98215
99732
|
if (def.carried && confiner && !confiner.empty) {
|
|
98216
|
-
|
|
98217
|
-
|
|
99733
|
+
STEP.x0 = this.position[i3];
|
|
99734
|
+
STEP.y0 = this.position[i3 + 1];
|
|
99735
|
+
STEP.z0 = this.position[i3 + 2];
|
|
99736
|
+
STEP.x1 = x;
|
|
99737
|
+
STEP.y1 = y;
|
|
99738
|
+
STEP.z1 = z;
|
|
99739
|
+
STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
|
|
99740
|
+
if (confiner.confineMove(STEP, dt)) {
|
|
98218
99741
|
const out = confiner.out;
|
|
98219
99742
|
x = out.x;
|
|
98220
99743
|
y = out.y;
|
|
98221
99744
|
z = out.z;
|
|
98222
|
-
|
|
99745
|
+
VELOCITY2.vx = vx2;
|
|
99746
|
+
VELOCITY2.vy = vy2;
|
|
99747
|
+
VELOCITY2.vz = vz2;
|
|
99748
|
+
slideInto(out, VELOCITY2);
|
|
99749
|
+
vx2 = VELOCITY2.vx;
|
|
99750
|
+
vy2 = VELOCITY2.vy;
|
|
99751
|
+
vz2 = VELOCITY2.vz;
|
|
98223
99752
|
}
|
|
98224
99753
|
}
|
|
98225
99754
|
if (def.ground !== "none") {
|
|
98226
99755
|
const own = this.floor[i];
|
|
98227
|
-
const
|
|
99756
|
+
const ground = this.ground;
|
|
99757
|
+
if (Number.isNaN(own) && !(Math.abs(x - ground[i3]) < GROUND_RESAMPLE && Math.abs(z - ground[i3 + 1]) < GROUND_RESAMPLE)) {
|
|
99758
|
+
ground[i3] = x;
|
|
99759
|
+
ground[i3 + 1] = z;
|
|
99760
|
+
ground[i3 + 2] = host.groundAt(x, z);
|
|
99761
|
+
}
|
|
99762
|
+
const gy = Number.isNaN(own) ? ground[i3 + 2] + 5e-3 : own;
|
|
98228
99763
|
if (y < gy) {
|
|
98229
99764
|
if (def.ground === "land") {
|
|
98230
99765
|
const tag = this.tag[i];
|
|
@@ -99070,10 +100605,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99070
100605
|
if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
|
|
99071
100606
|
particle.vy -= particle.gravity * dt;
|
|
99072
100607
|
if (particle.drag) {
|
|
99073
|
-
const
|
|
99074
|
-
particle.vx *=
|
|
99075
|
-
particle.vy *=
|
|
99076
|
-
particle.vz *=
|
|
100608
|
+
const keep2 = Math.max(0, 1 - particle.drag * dt);
|
|
100609
|
+
particle.vx *= keep2;
|
|
100610
|
+
particle.vy *= keep2;
|
|
100611
|
+
particle.vz *= keep2;
|
|
99077
100612
|
}
|
|
99078
100613
|
if (particle.carried) this.ride(particle, dt);
|
|
99079
100614
|
else {
|
|
@@ -99236,10 +100771,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99236
100771
|
const offset = index * FLOATS_PER_VECTOR;
|
|
99237
100772
|
const age = 1 - this.life[index] / this.maxLife[index];
|
|
99238
100773
|
velocity2[offset + 1] -= this.gravity[index] * dt;
|
|
99239
|
-
const
|
|
99240
|
-
velocity2[offset] *=
|
|
99241
|
-
velocity2[offset + 1] *=
|
|
99242
|
-
velocity2[offset + 2] *=
|
|
100774
|
+
const factor2 = Math.max(0, 1 - this.drag[index] * dt);
|
|
100775
|
+
velocity2[offset] *= factor2;
|
|
100776
|
+
velocity2[offset + 1] *= factor2;
|
|
100777
|
+
velocity2[offset + 2] *= factor2;
|
|
99243
100778
|
const x0 = position[offset];
|
|
99244
100779
|
const y0 = position[offset + 1];
|
|
99245
100780
|
const z0 = position[offset + 2];
|
|
@@ -99387,10 +100922,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99387
100922
|
const offset = index * FLOATS_PER_VECTOR2;
|
|
99388
100923
|
const age = 1 - this.life[index] / this.maxLife[index];
|
|
99389
100924
|
velocity2[offset + 1] -= this.gravity[index] * dt;
|
|
99390
|
-
const
|
|
99391
|
-
velocity2[offset] *=
|
|
99392
|
-
velocity2[offset + 1] *=
|
|
99393
|
-
velocity2[offset + 2] *=
|
|
100925
|
+
const factor2 = Math.max(0, 1 - this.drag[index] * dt);
|
|
100926
|
+
velocity2[offset] *= factor2;
|
|
100927
|
+
velocity2[offset + 1] *= factor2;
|
|
100928
|
+
velocity2[offset + 2] *= factor2;
|
|
99394
100929
|
point[offset] += velocity2[offset] * dt;
|
|
99395
100930
|
point[offset + 1] += velocity2[offset + 1] * dt;
|
|
99396
100931
|
point[offset + 2] += velocity2[offset + 2] * dt;
|
|
@@ -99726,16 +101261,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99726
101261
|
if (profile === void 0) return PROFILES.medium;
|
|
99727
101262
|
return typeof profile === "string" ? PROFILES[profile] : profile;
|
|
99728
101263
|
}
|
|
99729
|
-
function scaleDefinition(def,
|
|
99730
|
-
if (
|
|
99731
|
-
const mushroom = def.mushroom && { ...def.mushroom, height: def.mushroom.height *
|
|
99732
|
-
const residual = def.residualFires?.map((fire) => ({ ...fire, radius: fire.radius *
|
|
101264
|
+
function scaleDefinition(def, factor2) {
|
|
101265
|
+
if (factor2 === 1) return def;
|
|
101266
|
+
const mushroom = def.mushroom && { ...def.mushroom, height: def.mushroom.height * factor2, radius: def.mushroom.radius * factor2 };
|
|
101267
|
+
const residual = def.residualFires?.map((fire) => ({ ...fire, radius: fire.radius * factor2, dx: (fire.dx ?? 0) * factor2, dz: (fire.dz ?? 0) * factor2 }));
|
|
99733
101268
|
return {
|
|
99734
101269
|
...def,
|
|
99735
|
-
lethal: def.lethal *
|
|
99736
|
-
injury: def.injury *
|
|
99737
|
-
visualRadius: def.visualRadius *
|
|
99738
|
-
mark: { scorch: def.mark.scorch && def.mark.scorch *
|
|
101270
|
+
lethal: def.lethal * factor2,
|
|
101271
|
+
injury: def.injury * factor2,
|
|
101272
|
+
visualRadius: def.visualRadius * factor2,
|
|
101273
|
+
mark: { scorch: def.mark.scorch && def.mark.scorch * factor2, crater: def.mark.crater && def.mark.crater * factor2, dent: def.mark.dent && def.mark.dent * factor2 },
|
|
99739
101274
|
...mushroom ? { mushroom } : {},
|
|
99740
101275
|
...residual ? { residualFires: residual } : {}
|
|
99741
101276
|
};
|
|
@@ -99766,6 +101301,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99766
101301
|
});
|
|
99767
101302
|
const core = {
|
|
99768
101303
|
profile,
|
|
101304
|
+
confiner: enclosures,
|
|
99769
101305
|
puffs: createPuffPool(profile.puffs),
|
|
99770
101306
|
sparks: createSparkPool(profile.sparks),
|
|
99771
101307
|
glows: createGlowPool(profile.glows),
|
|
@@ -99906,6 +101442,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99906
101442
|
enclose(id, enclosure) {
|
|
99907
101443
|
enclosures.set(id, enclosure);
|
|
99908
101444
|
},
|
|
101445
|
+
solid(id, query2) {
|
|
101446
|
+
enclosures.solid(id, query2);
|
|
101447
|
+
},
|
|
99909
101448
|
enclosures: () => enclosures,
|
|
99910
101449
|
stop(handle) {
|
|
99911
101450
|
player?.stop(handle);
|
|
@@ -99913,10 +101452,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99913
101452
|
for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
|
|
99914
101453
|
},
|
|
99915
101454
|
clearSource(source) {
|
|
99916
|
-
const
|
|
101455
|
+
const keep2 = (record, gone) => record.source !== gone;
|
|
99917
101456
|
const drop = (pool) => {
|
|
99918
101457
|
const before = pool.count;
|
|
99919
|
-
pool.compact(
|
|
101458
|
+
pool.compact(keep2, source);
|
|
99920
101459
|
return before - pool.count;
|
|
99921
101460
|
};
|
|
99922
101461
|
return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
|
|
@@ -100013,7 +101552,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
100013
101552
|
}
|
|
100014
101553
|
var DEGREES = 180 / Math.PI;
|
|
100015
101554
|
|
|
100016
|
-
// ../game-vfx-three/dist/chunk-
|
|
101555
|
+
// ../game-vfx-three/dist/chunk-JM23474M.js
|
|
100017
101556
|
var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
|
|
100018
101557
|
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]);
|
|
100019
101558
|
vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
|
|
@@ -100027,23 +101566,24 @@ float vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);
|
|
|
100027
101566
|
return mix(mix(mix(h3(i),h3(i+vec3(1,0,0)),f.x),mix(h3(i+vec3(0,1,0)),h3(i+vec3(1,1,0)),f.x),f.y),
|
|
100028
101567
|
mix(mix(h3(i+vec3(0,0,1)),h3(i+vec3(1,0,1)),f.x),mix(h3(i+vec3(0,1,1)),h3(i+vec3(1,1,1)),f.x),f.y),f.z);}
|
|
100029
101568
|
`;
|
|
101569
|
+
var PUFF_BASE = (PUFF_REACH - 0.5).toFixed(2);
|
|
100030
101570
|
var PUFF_VERTEX = `${GL_NOISE}
|
|
100031
|
-
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
|
|
101571
|
+
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;attribute vec4 aK;attribute vec4 aK2;varying vec4 vK;varying vec4 vK2;
|
|
100032
101572
|
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
100033
101573
|
void main(){
|
|
100034
101574
|
vec3 p=position;
|
|
100035
101575
|
float s=aD.z;
|
|
100036
101576
|
float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
|
|
100037
|
-
p
|
|
101577
|
+
p*=${PUFF_BASE}+0.5*n;
|
|
100038
101578
|
float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;
|
|
100039
101579
|
vL=p;
|
|
100040
101580
|
vec3 wp=aP.xyz+p*aP.w;
|
|
100041
|
-
vWP=wp;vD=aD;vC=aC;
|
|
101581
|
+
vWP=wp;vD=aD;vC=aC;vK=aK;vK2=aK2;
|
|
100042
101582
|
gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
|
|
100043
101583
|
}`;
|
|
100044
101584
|
var PUFF_FRAGMENT = `${GL_NOISE}
|
|
100045
101585
|
uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
|
|
100046
|
-
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
101586
|
+
varying vec4 vK;varying vec4 vK2;varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
100047
101587
|
vec3 L(vec3 c){return pow(c,vec3(2.2));}
|
|
100048
101588
|
vec3 ramp(float h){
|
|
100049
101589
|
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));
|
|
@@ -100053,6 +101593,8 @@ vec3 ramp(float h){
|
|
|
100053
101593
|
return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
|
|
100054
101594
|
}
|
|
100055
101595
|
void main(){
|
|
101596
|
+
// cut at the face of a wall within reach (Puff.cuts): smoke flattens on the wall, it does not show through on its other side
|
|
101597
|
+
if(dot(vWP,vK.xyz)<vK.w||dot(vWP,vK2.xyz)<vK2.w)discard;
|
|
100056
101598
|
vec3 N=normalize(cross(dFdx(vWP),dFdy(vWP)));
|
|
100057
101599
|
float age=vD.x,heat=vD.y,kind=vD.w;
|
|
100058
101600
|
float n=vn(vL*2.4+vD.z*13.0);
|
|
@@ -100081,23 +101623,23 @@ void main(){
|
|
|
100081
101623
|
#include <colorspace_fragment>
|
|
100082
101624
|
}`;
|
|
100083
101625
|
var SOFT_PUFF_VERTEX = `${GL_NOISE}
|
|
100084
|
-
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
|
|
101626
|
+
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;attribute vec4 aK;attribute vec4 aK2;varying vec4 vK;varying vec4 vK2;
|
|
100085
101627
|
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
100086
101628
|
void main(){
|
|
100087
101629
|
vec3 p=position;
|
|
100088
101630
|
vec3 q=normalize(position);
|
|
100089
101631
|
float s=aD.z;
|
|
100090
101632
|
float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
|
|
100091
|
-
p
|
|
101633
|
+
p*=${PUFF_BASE}+0.5*n;
|
|
100092
101634
|
float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;q.xz=mat2(c,-si,si,c)*q.xz;
|
|
100093
101635
|
vL=p;vN=q;
|
|
100094
101636
|
vec3 wp=aP.xyz+p*aP.w;
|
|
100095
|
-
vWP=wp;vD=aD;vC=aC;
|
|
101637
|
+
vWP=wp;vD=aD;vC=aC;vK=aK;vK2=aK2;
|
|
100096
101638
|
gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
|
|
100097
101639
|
}`;
|
|
100098
101640
|
var SOFT_PUFF_FRAGMENT = `${GL_NOISE}
|
|
100099
101641
|
uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
|
|
100100
|
-
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
101642
|
+
varying vec4 vK;varying vec4 vK2;varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
100101
101643
|
vec3 L(vec3 c){return pow(c,vec3(2.2));}
|
|
100102
101644
|
vec3 ramp(float h){
|
|
100103
101645
|
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));
|
|
@@ -100107,6 +101649,8 @@ vec3 ramp(float h){
|
|
|
100107
101649
|
return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
|
|
100108
101650
|
}
|
|
100109
101651
|
void main(){
|
|
101652
|
+
// cut at the face of a wall within reach (Puff.cuts): smoke flattens on the wall, it does not show through on its other side
|
|
101653
|
+
if(dot(vWP,vK.xyz)<vK.w||dot(vWP,vK2.xyz)<vK2.w)discard;
|
|
100110
101654
|
float age=vD.x,heat=vD.y,kind=vD.w;
|
|
100111
101655
|
float n=vn(vL*2.4+vD.z*13.0);
|
|
100112
101656
|
// the sphere's own normal, roughened by the noise: a billowing cloud, never facets
|
|
@@ -100170,6 +101714,13 @@ void main(){
|
|
|
100170
101714
|
function dynamic(THREE, array, size) {
|
|
100171
101715
|
return new THREE.InstancedBufferAttribute(array, size).setUsage(THREE.DynamicDrawUsage);
|
|
100172
101716
|
}
|
|
101717
|
+
var NO_CUT = -1e9;
|
|
101718
|
+
function writeCut(into, n, cut) {
|
|
101719
|
+
into[n * 4] = cut.on ? cut.nx : 0;
|
|
101720
|
+
into[n * 4 + 1] = cut.on ? cut.ny : 0;
|
|
101721
|
+
into[n * 4 + 2] = cut.on ? cut.nz : 0;
|
|
101722
|
+
into[n * 4 + 3] = cut.on ? cut.d : NO_CUT;
|
|
101723
|
+
}
|
|
100173
101724
|
var PUFF_DETAIL = { faceted: 1, soft: 2 };
|
|
100174
101725
|
function createPuffLayer(THREE, pool, uniforms, style = "faceted") {
|
|
100175
101726
|
const capacity = pool.capacity;
|
|
@@ -100178,10 +101729,14 @@ void main(){
|
|
|
100178
101729
|
const a = new Float32Array(capacity * 4);
|
|
100179
101730
|
const d = new Float32Array(capacity * 4);
|
|
100180
101731
|
const c = new Float32Array(capacity * 3);
|
|
100181
|
-
const
|
|
101732
|
+
const k = new Float32Array(capacity * 4);
|
|
101733
|
+
const k2 = new Float32Array(capacity * 4);
|
|
101734
|
+
const attributes = [dynamic(THREE, a, 4), dynamic(THREE, d, 4), dynamic(THREE, c, 3), dynamic(THREE, k, 4), dynamic(THREE, k2, 4)];
|
|
100182
101735
|
geometry.setAttribute("aP", attributes[0]);
|
|
100183
101736
|
geometry.setAttribute("aD", attributes[1]);
|
|
100184
101737
|
geometry.setAttribute("aC", attributes[2]);
|
|
101738
|
+
geometry.setAttribute("aK", attributes[3]);
|
|
101739
|
+
geometry.setAttribute("aK2", attributes[4]);
|
|
100185
101740
|
geometry.instanceCount = 0;
|
|
100186
101741
|
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 });
|
|
100187
101742
|
const mesh3 = new THREE.Mesh(geometry, material);
|
|
@@ -100203,6 +101758,8 @@ void main(){
|
|
|
100203
101758
|
c[n * 3] = p.color[0];
|
|
100204
101759
|
c[n * 3 + 1] = p.color[1];
|
|
100205
101760
|
c[n * 3 + 2] = p.color[2];
|
|
101761
|
+
writeCut(k, n, p.cuts[0]);
|
|
101762
|
+
writeCut(k2, n, p.cuts[1]);
|
|
100206
101763
|
n++;
|
|
100207
101764
|
}
|
|
100208
101765
|
geometry.instanceCount = n;
|
|
@@ -100846,6 +102403,7 @@ void main(){
|
|
|
100846
102403
|
}
|
|
100847
102404
|
};
|
|
100848
102405
|
}
|
|
102406
|
+
var SHOWN_FIELDS = 6;
|
|
100849
102407
|
var clamp5 = (value, min2, max2) => value < min2 ? min2 : value > max2 ? max2 : value;
|
|
100850
102408
|
function layer2(container, name, blend) {
|
|
100851
102409
|
const element = container.ownerDocument.createElement("div");
|
|
@@ -100863,8 +102421,20 @@ void main(){
|
|
|
100863
102421
|
const sides = layer2(container, "sides");
|
|
100864
102422
|
const gas = layer2(container, "gas");
|
|
100865
102423
|
const elements = [flash2, white, red, sides, gas];
|
|
102424
|
+
const shown = new Float64Array(SHOWN_FIELDS).fill(Number.NaN);
|
|
102425
|
+
const isShown2 = (state) => {
|
|
102426
|
+
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;
|
|
102427
|
+
shown[0] = state.flash;
|
|
102428
|
+
shown[1] = state.white;
|
|
102429
|
+
shown[2] = state.red;
|
|
102430
|
+
shown[3] = state.directionLeft;
|
|
102431
|
+
shown[4] = state.directionRight;
|
|
102432
|
+
shown[5] = state.gas;
|
|
102433
|
+
return same;
|
|
102434
|
+
};
|
|
100866
102435
|
return {
|
|
100867
102436
|
update(state) {
|
|
102437
|
+
if (isShown2(state)) return;
|
|
100868
102438
|
flash2.style.opacity = clamp5(state.flash, 0, 1).toFixed(3);
|
|
100869
102439
|
white.style.opacity = "1";
|
|
100870
102440
|
white.style.background = `rgba(235,240,255,${clamp5(state.white, 0, 1).toFixed(2)})`;
|
|
@@ -103256,9 +104826,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
103256
104826
|
hand.updateMatrixWorld(true);
|
|
103257
104827
|
const at4 = worldPositionOf(session, mark, muzzleAt);
|
|
103258
104828
|
if (lens2) toWorldLens(camera2, at4, worldFovOf(), lens2.fov);
|
|
103259
|
-
const
|
|
104829
|
+
const along3 = muzzleAlong.set(1, 0, 0).applyQuaternion(session.model.root.getWorldQuaternion(rootQuaternion)).normalize();
|
|
103260
104830
|
const kind = session.def.action.kind;
|
|
103261
|
-
return { position: [at4.x, at4.y, at4.z], direction: [
|
|
104831
|
+
return { position: [at4.x, at4.y, at4.z], direction: [along3.x, along3.y, along3.z], drawsFlash: kind === "firearm" || kind === "launcher" };
|
|
103262
104832
|
},
|
|
103263
104833
|
handTargets() {
|
|
103264
104834
|
const held = heldHold();
|
|
@@ -105431,7 +107001,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
105431
107001
|
var AFTERMATH_DELAY = 2;
|
|
105432
107002
|
var SHOOTER = "pistol_9mm";
|
|
105433
107003
|
var AIM_HEIGHT = 0.2;
|
|
105434
|
-
var
|
|
107004
|
+
var GRAVITY5 = 9.81;
|
|
105435
107005
|
var REPORTED_OBJECTS = ["fridge", "kitchen_cabinet_base", "stove", "camp_table"];
|
|
105436
107006
|
var RING_SEGMENTS = 128;
|
|
105437
107007
|
var WALL_ID = "target_wall";
|
|
@@ -105580,7 +107150,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
105580
107150
|
for (const shell of shells) {
|
|
105581
107151
|
if (shell.landed) continue;
|
|
105582
107152
|
shell.age += dt;
|
|
105583
|
-
shell.velocity[1] -=
|
|
107153
|
+
shell.velocity[1] -= GRAVITY5 * dt;
|
|
105584
107154
|
for (let axis2 = 0; axis2 < 3; axis2++) shell.position[axis2] = shell.position[axis2] + shell.velocity[axis2] * dt;
|
|
105585
107155
|
const ground = host.groundAt(shell.position[0], shell.position[2]) + 0.18;
|
|
105586
107156
|
if (shell.position[1] <= ground && shell.velocity[1] < 0) {
|
|
@@ -106057,7 +107627,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
106057
107627
|
origin.set(body.objectId, body.from);
|
|
106058
107628
|
}
|
|
106059
107629
|
const partsBefore = new Map(placed.map((body) => [body.objectId, partsOf(body.objectId)]));
|
|
106060
|
-
const partPlaces = (objectId,
|
|
107630
|
+
const partPlaces = (objectId, keep2 = () => true) => (room.world.state(objectId)?.parts ?? []).filter(keep2).map((part) => [part, { mass: part.mass, boxes: room.renderer.shownBoxes?.(objectId, part.id) ?? [] }]);
|
|
106061
107631
|
const heavyBefore = new Map(placed.filter((body) => HEAVY_ITEMS.includes(body.kind)).map((body) => [body.objectId, new Map(partPlaces(body.objectId))]));
|
|
106062
107632
|
const heavyShift = (objectId) => {
|
|
106063
107633
|
const before = heavyBefore.get(objectId);
|