@adatechnology/game-weapons-three 0.29.8 → 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 +781 -380
- package/dist/index.global.js.map +1 -1
- package/package.json +8 -8
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;
|
|
@@ -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) {
|
|
@@ -25178,6 +25178,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25178
25178
|
var FOOT_BAND = 0.03;
|
|
25179
25179
|
var SEAM_STATIONS = 5;
|
|
25180
25180
|
var BEAM_PIECES = 4;
|
|
25181
|
+
var SAG_STATIONS = BEAM_PIECES + 1;
|
|
25181
25182
|
var SLENDER = 4;
|
|
25182
25183
|
var MAX_DOF = 1500;
|
|
25183
25184
|
var MECHANISM = 0.5;
|
|
@@ -25209,6 +25210,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25209
25210
|
const r = t / b;
|
|
25210
25211
|
return b * t ** 3 * (1 / 3 - 0.21 * r * (1 - r ** 4 / 12));
|
|
25211
25212
|
}
|
|
25213
|
+
var NO_PLACES = new Int32Array(0);
|
|
25212
25214
|
var AXES = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
25213
25215
|
function beamOf(part) {
|
|
25214
25216
|
const d = part.dims;
|
|
@@ -25245,8 +25247,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25245
25247
|
if (d[2] > d[a]) a = 2;
|
|
25246
25248
|
const du = d[(a + 1) % 3];
|
|
25247
25249
|
const dv = d[(a + 2) % 3];
|
|
25248
|
-
const
|
|
25249
|
-
const e = (
|
|
25250
|
+
const along3 = beam.part.grain === void 0 || beam.part.grain === a;
|
|
25251
|
+
const e = (along3 ? elastic.alongGPa : elastic.acrossGPa ?? elastic.alongGPa) * 1e9;
|
|
25250
25252
|
const g = elastic.shearGPa * 1e9;
|
|
25251
25253
|
if (beam.part.round && a === 1) {
|
|
25252
25254
|
const r = du / 2;
|
|
@@ -25353,17 +25355,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25353
25355
|
let c = (n + 2) % 3;
|
|
25354
25356
|
if (size[c] > size[w]) [w, c] = [c, w];
|
|
25355
25357
|
const frame2 = [AXES[n], AXES[w], AXES[c]];
|
|
25356
|
-
const
|
|
25358
|
+
const along3 = size[w];
|
|
25357
25359
|
const across2 = size[c];
|
|
25358
25360
|
const d = fastener?.diameter ?? 5e-3;
|
|
25359
25361
|
const spacing = fastener?.spacing ?? 0.2;
|
|
25360
25362
|
const end3 = END_D * d;
|
|
25361
|
-
const count =
|
|
25363
|
+
const count = along3 > 2 * end3 ? 1 + Math.ceil((along3 - 2 * end3) / spacing) : 1;
|
|
25362
25364
|
const stations = Math.min(count, SEAM_STATIONS);
|
|
25363
25365
|
const each = count / stations;
|
|
25364
25366
|
const out = [];
|
|
25365
25367
|
for (let s = 0; s < stations; s++) {
|
|
25366
|
-
const t = stations === 1 ? 0 : -
|
|
25368
|
+
const t = stations === 1 ? 0 : -along3 / 2 + end3 + (along3 - 2 * end3) * s / (stations - 1);
|
|
25367
25369
|
const at4 = [middle[0], middle[1], middle[2]];
|
|
25368
25370
|
at4[w] = middle[w] + t;
|
|
25369
25371
|
if (stiff || !fastener) {
|
|
@@ -25373,43 +25375,148 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25373
25375
|
const rows = across2 >= (2 * EDGE_D + ROW_D) * d ? [EDGE_D * d, across2 - EDGE_D * d] : [across2 / 2];
|
|
25374
25376
|
const pry = rows.reduce((sum2, r) => sum2 + r * r, 0) * fastener.axial * each;
|
|
25375
25377
|
const lone = stations === 1;
|
|
25376
|
-
const pryAlong = lone ? (
|
|
25378
|
+
const pryAlong = lone ? (along3 / 2) ** 2 * fastener.axial * rows.length : 0;
|
|
25377
25379
|
const twist = lone && rows.length > 1 ? rows.reduce((sum2, r) => sum2 + (r - across2 / 2) ** 2, 0) * fastener.lateral : 0;
|
|
25378
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] });
|
|
25379
25381
|
}
|
|
25380
25382
|
return out;
|
|
25381
25383
|
}
|
|
25382
|
-
function
|
|
25383
|
-
const
|
|
25384
|
-
for (
|
|
25385
|
-
|
|
25386
|
-
|
|
25387
|
-
|
|
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]);
|
|
25388
25423
|
}
|
|
25389
|
-
|
|
25390
|
-
|
|
25391
|
-
|
|
25392
|
-
|
|
25393
|
-
|
|
25394
|
-
|
|
25395
|
-
|
|
25396
|
-
|
|
25397
|
-
|
|
25398
|
-
|
|
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]];
|
|
25399
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);
|
|
25400
25492
|
}
|
|
25401
|
-
|
|
25402
|
-
|
|
25403
|
-
|
|
25404
|
-
|
|
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;
|
|
25405
25501
|
}
|
|
25406
|
-
for (let
|
|
25407
|
-
|
|
25408
|
-
|
|
25409
|
-
|
|
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];
|
|
25410
25506
|
}
|
|
25411
|
-
return true;
|
|
25412
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
|
+
};
|
|
25413
25520
|
function hullOf(points) {
|
|
25414
25521
|
const sorted = [...points].sort((p, q) => p[0] - q[0] || p[1] - q[1]);
|
|
25415
25522
|
const turn2 = (o, p, q) => (p[0] - o[0]) * (q[1] - o[1]) - (p[1] - o[1]) * (q[0] - o[0]);
|
|
@@ -25441,7 +25548,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25441
25548
|
const joints = input.joints.filter((j) => beams.has(j.a) && beams.has(j.b) && j.a !== j.b);
|
|
25442
25549
|
const structural = (j) => RIGID_KINDS.has(j.kind) || JOINT_FASTENERS[j.kind] !== void 0;
|
|
25443
25550
|
const stationed = /* @__PURE__ */ new Map();
|
|
25444
|
-
const
|
|
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)));
|
|
25445
25552
|
for (const beam of beams.values()) beam.stations.push(-beam.length / 2, beam.length / 2);
|
|
25446
25553
|
for (const joint2 of joints) {
|
|
25447
25554
|
if (!structural(joint2)) continue;
|
|
@@ -25450,8 +25557,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25450
25557
|
const stations = stationsOf(joint2, a, b);
|
|
25451
25558
|
stationed.set(joint2, stations);
|
|
25452
25559
|
for (const s of stations) {
|
|
25453
|
-
a.stations.push(
|
|
25454
|
-
b.stations.push(
|
|
25560
|
+
a.stations.push(along3(a, s.at));
|
|
25561
|
+
b.stations.push(along3(b, s.at));
|
|
25455
25562
|
}
|
|
25456
25563
|
}
|
|
25457
25564
|
const footPoints = /* @__PURE__ */ new Map();
|
|
@@ -25463,7 +25570,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25463
25570
|
if (c[1] <= beam.min[1] + 5e-3) corners.push(c);
|
|
25464
25571
|
}
|
|
25465
25572
|
footPoints.set(beam.part.id, corners);
|
|
25466
|
-
for (const c of corners) beam.stations.push(
|
|
25573
|
+
for (const c of corners) beam.stations.push(along3(beam, c));
|
|
25467
25574
|
}
|
|
25468
25575
|
const nodes = [];
|
|
25469
25576
|
for (const beam of beams.values()) {
|
|
@@ -25487,28 +25594,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25487
25594
|
beam.nodes = kept.map((s) => nodes.push({ at: vec.madd(beam.part.position, beam.axis, s) }) - 1);
|
|
25488
25595
|
}
|
|
25489
25596
|
if (nodes.length * 6 > MAX_DOF) return null;
|
|
25490
|
-
const lo = [Infinity, Infinity, Infinity];
|
|
25491
|
-
const hi = [-Infinity, -Infinity, -Infinity];
|
|
25492
|
-
for (const node of nodes) for (let k = 0; k < 3; k++) {
|
|
25493
|
-
lo[k] = Math.min(lo[k], node.at[k]);
|
|
25494
|
-
hi[k] = Math.max(hi[k], node.at[k]);
|
|
25495
|
-
}
|
|
25496
|
-
let main = 0;
|
|
25497
|
-
if (hi[1] - lo[1] > hi[main] - lo[main]) main = 1;
|
|
25498
|
-
if (hi[2] - lo[2] > hi[main] - lo[main]) main = 2;
|
|
25499
|
-
const ranked = nodes.map((_, i) => i).sort((p, q) => nodes[p].at[main] - nodes[q].at[main] || p - q);
|
|
25500
25597
|
const order2 = new Int32Array(nodes.length);
|
|
25501
|
-
|
|
25502
|
-
order2[node] = rank;
|
|
25503
|
-
});
|
|
25598
|
+
for (let i = 0; i < nodes.length; i++) order2[i] = i;
|
|
25504
25599
|
const dofsOf = (node) => [0, 1, 2, 3, 4, 5].map((i) => order2[node] * 6 + i);
|
|
25505
25600
|
const nearest = (beam, p) => {
|
|
25506
|
-
const t =
|
|
25601
|
+
const t = along3(beam, p);
|
|
25507
25602
|
let best = 0;
|
|
25508
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;
|
|
25509
25604
|
return beam.nodes[best];
|
|
25510
25605
|
};
|
|
25511
|
-
const
|
|
25606
|
+
const made = [];
|
|
25512
25607
|
for (const beam of beams.values()) {
|
|
25513
25608
|
const section = sectionOf2(beam);
|
|
25514
25609
|
if (!section) {
|
|
@@ -25519,7 +25614,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25519
25614
|
for (let i = 0; i + 1 < beam.nodes.length; i++) {
|
|
25520
25615
|
const length2 = beam.stations[i + 1] - beam.stations[i];
|
|
25521
25616
|
const k = toObjectFrame(beamLocal(section, length2), 12, beam.axis, beam.u, beam.v);
|
|
25522
|
-
|
|
25617
|
+
made.push({ dofs: [...dofsOf(beam.nodes[i]), ...dofsOf(beam.nodes[i + 1])], k, parts: [beam.part.id], places: NO_PLACES });
|
|
25523
25618
|
}
|
|
25524
25619
|
}
|
|
25525
25620
|
for (const [joint2, stations] of stationed) {
|
|
@@ -25548,7 +25643,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25548
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];
|
|
25549
25644
|
}
|
|
25550
25645
|
}
|
|
25551
|
-
|
|
25646
|
+
made.push({ dofs: [...dofsOf(na), ...dofsOf(nb)], k, parts: [joint2.a, joint2.b], places: NO_PLACES });
|
|
25552
25647
|
}
|
|
25553
25648
|
}
|
|
25554
25649
|
const supports = [];
|
|
@@ -25559,7 +25654,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25559
25654
|
supports.push({ part: id, node, arm: vec.sub(at4, nodes[node].at), at: at4 });
|
|
25560
25655
|
}
|
|
25561
25656
|
}
|
|
25562
|
-
const
|
|
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 };
|
|
25563
25666
|
const before = lost.size > 0 ? solveFrame(frame2, input, joints, structural, /* @__PURE__ */ new Set(), g, null) : null;
|
|
25564
25667
|
const after2 = solveFrame(frame2, input, joints, structural, lost, g, before);
|
|
25565
25668
|
if (!after2) return null;
|
|
@@ -25599,12 +25702,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25599
25702
|
const delta = new Float64Array(n);
|
|
25600
25703
|
for (let i = 0; i < n; i++) delta[i] = after2.u[i] - before.u[i];
|
|
25601
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;
|
|
25602
|
-
|
|
25603
|
-
if (delta[i] === 0) continue;
|
|
25604
|
-
let row = 0;
|
|
25605
|
-
for (let j = 0; j < n; j++) row += after2.k[i * n + j] * delta[j];
|
|
25606
|
-
released += 0.5 * delta[i] * row;
|
|
25607
|
-
}
|
|
25705
|
+
released = frame2.shape.halfQuadratic(after2.k, delta);
|
|
25608
25706
|
spin = spinOf({ frame: frame2, after: after2, delta, released, centre: allCentre, mass: all, floor: floor2, g });
|
|
25609
25707
|
}
|
|
25610
25708
|
return {
|
|
@@ -25619,6 +25717,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25619
25717
|
if (!beam || !after2.standing.has(id)) return null;
|
|
25620
25718
|
const node = nearest(beam, point);
|
|
25621
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 };
|
|
25622
25735
|
}
|
|
25623
25736
|
};
|
|
25624
25737
|
}
|
|
@@ -25643,7 +25756,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25643
25756
|
return standing;
|
|
25644
25757
|
}
|
|
25645
25758
|
function solveFrame(frame2, input, joints, structural, gone, g, from) {
|
|
25646
|
-
const { nodes, beams, order: order2 } = frame2;
|
|
25759
|
+
const { nodes, beams, order: order2, shape } = frame2;
|
|
25647
25760
|
const n = nodes.length * 6;
|
|
25648
25761
|
const standing = standingParts(frame2, joints, structural, gone);
|
|
25649
25762
|
if (standing.size === 0) return null;
|
|
@@ -25703,50 +25816,50 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25703
25816
|
f[base2 + 3] = f[base2 + 3] - p.arm[2] * weight;
|
|
25704
25817
|
f[base2 + 5] = f[base2 + 5] + p.arm[0] * weight;
|
|
25705
25818
|
}
|
|
25706
|
-
const structure = new Float64Array(
|
|
25819
|
+
const structure = new Float64Array(shape.size);
|
|
25707
25820
|
let largest = 0;
|
|
25708
25821
|
for (const element of frame2.elements) {
|
|
25709
25822
|
if (!element.parts.every((id) => standing.has(id))) continue;
|
|
25710
|
-
const
|
|
25711
|
-
for (let
|
|
25712
|
-
for (let q = 0; q < size; q++) structure[element.dofs[p] * n + element.dofs[q]] = structure[element.dofs[p] * n + element.dofs[q]] + element.k[p * size + q];
|
|
25713
|
-
}
|
|
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];
|
|
25714
25825
|
}
|
|
25715
|
-
for (let i = 0; i < n; i++) largest = Math.max(largest, structure[i
|
|
25826
|
+
for (let i = 0; i < n; i++) largest = Math.max(largest, structure[i]);
|
|
25716
25827
|
if (largest <= 0) return null;
|
|
25717
25828
|
const free = new Uint8Array(n);
|
|
25718
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;
|
|
25719
25830
|
for (let i = 0; i < n; i++) {
|
|
25720
25831
|
if (!free[i]) {
|
|
25721
|
-
structure[i
|
|
25832
|
+
structure[i] = largest;
|
|
25722
25833
|
f[i] = 0;
|
|
25723
|
-
} else structure
|
|
25834
|
+
} else addAt(shape, structure, i, i, largest * SOFT);
|
|
25724
25835
|
}
|
|
25725
25836
|
const feet = frame2.supports.filter((s) => standing.has(s.part));
|
|
25726
25837
|
const holds3 = feet.map((s) => !from || from.holding.includes(s));
|
|
25727
25838
|
const footed = [...new Set(feet.map((s) => s.part))];
|
|
25728
25839
|
const grips = new Map(footed.map((id) => [id, true]));
|
|
25729
25840
|
const friction = input.friction ?? FOOT_FRICTION;
|
|
25730
|
-
const
|
|
25841
|
+
const factored = structure.slice();
|
|
25842
|
+
if (!shape.factor(factored, 0, shape.head)) return null;
|
|
25843
|
+
const k = new Float64Array(shape.size);
|
|
25731
25844
|
const u = new Float64Array(n);
|
|
25732
|
-
const build = () => {
|
|
25733
|
-
k.set(
|
|
25845
|
+
const build = (from2) => {
|
|
25846
|
+
k.set(from2);
|
|
25734
25847
|
const held = /* @__PURE__ */ new Map();
|
|
25735
25848
|
feet.forEach((s, index) => {
|
|
25736
25849
|
if (!holds3[index]) return;
|
|
25737
25850
|
const row = armRows(s.arm)[1];
|
|
25738
25851
|
const base2 = order2[s.node] * 6;
|
|
25739
|
-
for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++)
|
|
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]);
|
|
25740
25853
|
held.set(s.part, [...held.get(s.part) ?? [], s]);
|
|
25741
25854
|
});
|
|
25742
25855
|
for (const [id, points] of held) {
|
|
25743
25856
|
const { node, arm } = gripOf(points);
|
|
25744
25857
|
const upright = order2[node] * 6 + 4;
|
|
25745
|
-
k
|
|
25858
|
+
addAt(shape, k, upright, upright, RIGID_TURN);
|
|
25746
25859
|
if (!grips.get(id)) continue;
|
|
25747
25860
|
const rows = armRows(arm);
|
|
25748
25861
|
const base2 = order2[node] * 6;
|
|
25749
|
-
for (const row of [rows[0], rows[2]]) for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++)
|
|
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]);
|
|
25750
25863
|
}
|
|
25751
25864
|
};
|
|
25752
25865
|
const liftOf = (s) => {
|
|
@@ -25755,9 +25868,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25755
25868
|
};
|
|
25756
25869
|
const rounds = 4 * feet.length + 2 * footed.length + 4;
|
|
25757
25870
|
for (let round5 = 0; round5 < rounds; round5++) {
|
|
25758
|
-
build();
|
|
25871
|
+
build(factored);
|
|
25759
25872
|
u.set(f);
|
|
25760
|
-
if (!
|
|
25873
|
+
if (!shape.factor(k, shape.head, n)) return null;
|
|
25874
|
+
shape.substitute(k, u);
|
|
25761
25875
|
const pull = 1e-12;
|
|
25762
25876
|
const sink = -1e-9;
|
|
25763
25877
|
if (round5 === 0) {
|
|
@@ -25811,7 +25925,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25811
25925
|
if (worst > MECHANISM) return null;
|
|
25812
25926
|
const holding = feet.filter((_, index) => holds3[index]);
|
|
25813
25927
|
if (holding.length < 3) return null;
|
|
25814
|
-
build();
|
|
25928
|
+
build(structure);
|
|
25815
25929
|
return { u: u.slice(), k: k.slice(), holding, masses, standing };
|
|
25816
25930
|
}
|
|
25817
25931
|
return null;
|
|
@@ -26130,8 +26244,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26130
26244
|
};
|
|
26131
26245
|
var sectionKept = (p, residual, borne, through) => {
|
|
26132
26246
|
let kept = 1;
|
|
26133
|
-
forEachSection(p, borne, (c,
|
|
26134
|
-
const share = through?.(c.center,
|
|
26247
|
+
forEachSection(p, borne, (c, along3, gone) => {
|
|
26248
|
+
const share = through?.(c.center, along3) ?? 1;
|
|
26135
26249
|
if (share <= 0) return;
|
|
26136
26250
|
kept = Math.min(kept, Math.max(p.spec.reinforcement ? residual : 0, 1 - gone) / share);
|
|
26137
26251
|
});
|
|
@@ -26156,12 +26270,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26156
26270
|
const last = cells[cells.length - 1];
|
|
26157
26271
|
if (!known || known.spec !== p.spec || known.count !== cells.length || known.last !== last) {
|
|
26158
26272
|
const places = [];
|
|
26159
|
-
let
|
|
26273
|
+
let along3 = 0;
|
|
26160
26274
|
measureSections(p, cells, void 0, (c, a, gone) => {
|
|
26161
|
-
|
|
26275
|
+
along3 = a;
|
|
26162
26276
|
places.push({ c, gone });
|
|
26163
26277
|
});
|
|
26164
|
-
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 };
|
|
26165
26279
|
sectionsByCells.set(cells, known);
|
|
26166
26280
|
}
|
|
26167
26281
|
for (const { c, gone } of known.places) {
|
|
@@ -26169,24 +26283,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26169
26283
|
visit(c, known.along, gone);
|
|
26170
26284
|
}
|
|
26171
26285
|
};
|
|
26172
|
-
var sectionLying = (p,
|
|
26286
|
+
var sectionLying = (p, along3) => {
|
|
26173
26287
|
const [u, v] = planeAxes(p.thin);
|
|
26174
26288
|
const up = rotateVec(p.q, [0, 0, 0].map((_, k) => k === v ? 1 : 0));
|
|
26175
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;
|
|
26176
|
-
return
|
|
26290
|
+
return along3 !== upright || upright < 0;
|
|
26177
26291
|
};
|
|
26178
26292
|
var measureSections = (p, cells, borne, visit) => {
|
|
26179
26293
|
const [u, v] = planeAxes(p.thin);
|
|
26180
26294
|
const role = p.spec.structure?.role;
|
|
26181
26295
|
const up = rotateVec(p.q, [0, 0, 0].map((_, k) => k === v ? 1 : 0));
|
|
26182
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;
|
|
26183
|
-
const
|
|
26184
|
-
const across2 =
|
|
26185
|
-
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;
|
|
26186
26300
|
for (const c of cells) {
|
|
26187
|
-
if (lying && borne?.(c.center,
|
|
26301
|
+
if (lying && borne?.(c.center, along3)) continue;
|
|
26188
26302
|
const spans = [];
|
|
26189
|
-
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]);
|
|
26190
26304
|
spans.sort((a, b) => a[0] - b[0]);
|
|
26191
26305
|
let gone = 0, end3 = -Infinity;
|
|
26192
26306
|
for (const [a, b] of spans) {
|
|
@@ -26194,7 +26308,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26194
26308
|
gone += b - Math.max(a, end3);
|
|
26195
26309
|
end3 = b;
|
|
26196
26310
|
}
|
|
26197
|
-
visit(c,
|
|
26311
|
+
visit(c, along3, Math.min(1, gone / Math.max(p.dims[across2], 1e-6)));
|
|
26198
26312
|
}
|
|
26199
26313
|
};
|
|
26200
26314
|
var HOSTED_TOLERANCE = 0.02;
|
|
@@ -26266,6 +26380,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26266
26380
|
const primed = /* @__PURE__ */ new Map();
|
|
26267
26381
|
let orderCounter = 0;
|
|
26268
26382
|
const impls = /* @__PURE__ */ new Map();
|
|
26383
|
+
let implsRevision = 0;
|
|
26269
26384
|
const taken = (id) => objects.has(id) || impls.has(id);
|
|
26270
26385
|
const emit2 = (e) => {
|
|
26271
26386
|
cur.push(e);
|
|
@@ -26653,13 +26768,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26653
26768
|
if (load <= 0) return void 0;
|
|
26654
26769
|
const above2 = Math.max(0, load - p.st.mass);
|
|
26655
26770
|
const up = rotateVec(p.q, [0, 1, 0]);
|
|
26656
|
-
return (local2,
|
|
26771
|
+
return (local2, along3) => {
|
|
26657
26772
|
const axis2 = [0, 0, 0];
|
|
26658
|
-
axis2[
|
|
26773
|
+
axis2[along3] = 1;
|
|
26659
26774
|
const sign2 = Math.sign(rotateVec(p.q, axis2)[1]);
|
|
26660
26775
|
if (Math.abs(up[1]) < 0.7 && Math.abs(rotateVec(p.q, axis2)[1]) < 0.7) return 1;
|
|
26661
|
-
const half = p.dims[
|
|
26662
|
-
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);
|
|
26663
26778
|
return (above2 + p.st.mass * share) / load;
|
|
26664
26779
|
};
|
|
26665
26780
|
};
|
|
@@ -26721,7 +26836,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26721
26836
|
const borneOn = (p, supports) => {
|
|
26722
26837
|
if (supports.length === 0) return void 0;
|
|
26723
26838
|
const boxes = supports.map((support) => contactBox(p, support));
|
|
26724
|
-
return (local2,
|
|
26839
|
+
return (local2, along3) => boxes.some(([lo, hi]) => local2[along3] >= lo[along3] - SUPPORT_TOLERANCE && local2[along3] <= hi[along3] + SUPPORT_TOLERANCE);
|
|
26725
26840
|
};
|
|
26726
26841
|
const measureContact = (p, support) => {
|
|
26727
26842
|
const A = aabbOf(p.spec.shape, p.pos, p.q), B = aabbOf(support.spec.shape, support.pos, support.q);
|
|
@@ -26826,14 +26941,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26826
26941
|
const kinetic = impulseEnergy(impulse, lineLoad(g, weight) / GRAVITY * L, flexure);
|
|
26827
26942
|
const sec = sectionOf22(p, axis2);
|
|
26828
26943
|
const EI = s.elasticGPa * 1e9 * sec.section.b * sec.section.h ** 3 / 12;
|
|
26829
|
-
const
|
|
26944
|
+
const along3 = axis2 === g.gravity ? -Math.sign(away[axis2] * g.up[axis2]) : 0;
|
|
26830
26945
|
const dynamic2 = momentOfEnergy(kinetic, L, EI, flexure.loadFactor);
|
|
26831
|
-
const peak = Math.abs(dynamic2 +
|
|
26946
|
+
const peak = Math.abs(dynamic2 + along3 * p.restMoment);
|
|
26832
26947
|
if (peak <= sec.cracking) return;
|
|
26833
26948
|
if (!p.st.cracked) {
|
|
26834
26949
|
p.st.cracked = true;
|
|
26835
26950
|
const tension = [near.point[0], near.point[1], near.point[2]];
|
|
26836
|
-
tension[axis2] = dynamic2 +
|
|
26951
|
+
tension[axis2] = dynamic2 + along3 * p.restMoment >= 0 ? -face : face;
|
|
26837
26952
|
const n = [0, 0, 0];
|
|
26838
26953
|
n[axis2] = Math.sign(tension[axis2]) || 1;
|
|
26839
26954
|
addCrack(o, p, toWorld(c, q, tension), rotateVec(q, n), sec.section.b, src);
|
|
@@ -27005,7 +27120,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27005
27120
|
if (!terrain) throw new Error(`unknown wind terrain "${cfg.terrain}"`);
|
|
27006
27121
|
const inputs = [];
|
|
27007
27122
|
const at4 = /* @__PURE__ */ new Map();
|
|
27008
|
-
const
|
|
27123
|
+
const keep2 = [];
|
|
27009
27124
|
let ground = Infinity, foundationTop = -Infinity;
|
|
27010
27125
|
o.parts.forEach((p, i) => {
|
|
27011
27126
|
if (isLost(p) || isTerrain(p) || o.collapsed.has(p.spec.id) || o.unsup[i]) return;
|
|
@@ -27014,12 +27129,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27014
27129
|
const e = p.mat.strength?.elasticGPa;
|
|
27015
27130
|
const kind = role === "wall" ? "wall" : role === "column" ? "column" : role === "beam" ? "beam" : role === "foundation" ? "foundation" : "other";
|
|
27016
27131
|
at4.set(i, inputs.length);
|
|
27017
|
-
|
|
27132
|
+
keep2.push(i);
|
|
27018
27133
|
ground = Math.min(ground, box5.min[1]);
|
|
27019
27134
|
if (kind === "foundation") foundationTop = Math.max(foundationTop, box5.max[1]);
|
|
27020
27135
|
inputs.push({ min: box5.min, max: box5.max, kind, ...e ? { elasticPa: e * 1e9 } : {}, mass: p.st.mass, ...p.spec.damper ? { damper: true } : {} });
|
|
27021
27136
|
});
|
|
27022
|
-
|
|
27137
|
+
keep2.forEach((i, k) => {
|
|
27023
27138
|
if (inputs[k].kind !== "column") return;
|
|
27024
27139
|
const beams = [];
|
|
27025
27140
|
for (const j of o.byPart.get(o.parts[i].spec.id)) {
|
|
@@ -27029,7 +27144,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27029
27144
|
}
|
|
27030
27145
|
inputs[k].beams = beams;
|
|
27031
27146
|
});
|
|
27032
|
-
|
|
27147
|
+
keep2.forEach((i, k) => {
|
|
27033
27148
|
if (inputs[k].kind !== "beam") return;
|
|
27034
27149
|
for (const j of o.byPart.get(o.parts[i].spec.id)) {
|
|
27035
27150
|
if (j.st.open) continue;
|
|
@@ -27063,14 +27178,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27063
27178
|
};
|
|
27064
27179
|
const a = inputs.length && cfg.speed > 0 ? analyzeWind(inputs, c, foundationTop > -Infinity ? foundationTop : ground) : null;
|
|
27065
27180
|
w.analysis = a;
|
|
27066
|
-
w.parts =
|
|
27181
|
+
w.parts = keep2;
|
|
27067
27182
|
for (const p of o.parts) delete p.st.wind;
|
|
27068
27183
|
if (!a) {
|
|
27069
27184
|
w.sys = null;
|
|
27070
27185
|
delete o.st.wind;
|
|
27071
27186
|
return;
|
|
27072
27187
|
}
|
|
27073
|
-
|
|
27188
|
+
keep2.forEach((i, k) => {
|
|
27074
27189
|
const N = a.axial[k];
|
|
27075
27190
|
const p = o.parts[i];
|
|
27076
27191
|
if (!N || !p.structural || o.unsup[i]) return;
|
|
@@ -27104,7 +27219,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27104
27219
|
w.gust = makeGust(v10, cfg.gust);
|
|
27105
27220
|
}
|
|
27106
27221
|
let md = 0, spec;
|
|
27107
|
-
for (const i of
|
|
27222
|
+
for (const i of keep2) {
|
|
27108
27223
|
const p = o.parts[i];
|
|
27109
27224
|
if (!p.spec.damper) continue;
|
|
27110
27225
|
const phi = shapeAt(a, p.pos[1] - (foundationTop > -Infinity ? foundationTop : ground));
|
|
@@ -27248,10 +27363,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27248
27363
|
iz += sp.k * (sp.z - z0) ** 2;
|
|
27249
27364
|
}
|
|
27250
27365
|
const { c } = soilWeight(o);
|
|
27251
|
-
const
|
|
27252
|
-
const off =
|
|
27366
|
+
const along3 = ix <= iz ? 0 : 1;
|
|
27367
|
+
const off = along3 === 0 ? c[0] - x0 : c[2] - z0;
|
|
27253
27368
|
const sign2 = Math.abs(off) > 1e-6 ? Math.sign(off) : 1;
|
|
27254
|
-
so.imp =
|
|
27369
|
+
so.imp = along3 === 0 ? [sign2 * soilCfg.imperfection, 0] : [0, sign2 * soilCfg.imperfection];
|
|
27255
27370
|
if (carried) {
|
|
27256
27371
|
const t = Math.tan(carried.tilt * Math.PI / 180);
|
|
27257
27372
|
so.s = carried.settlement;
|
|
@@ -27499,10 +27614,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27499
27614
|
const cut = undercutAt(loss, Math.hypot(world2[0] - loss.x, world2[2] - loss.z), b.embed, groundCfg.spread);
|
|
27500
27615
|
if (cut >= groundCfg.voidDepth) {
|
|
27501
27616
|
open++;
|
|
27502
|
-
const
|
|
27617
|
+
const along3 = local2[long] - box5.min[long];
|
|
27503
27618
|
const side = local2[across2] - box5.min[across2];
|
|
27504
|
-
voidBox ?? (voidBox = { long: [
|
|
27505
|
-
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)];
|
|
27506
27621
|
voidBox.across = [Math.min(voidBox.across[0], side), Math.max(voidBox.across[1], side)];
|
|
27507
27622
|
}
|
|
27508
27623
|
drop += Math.min(cut, groundCfg.maxSettlement);
|
|
@@ -27606,9 +27721,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27606
27721
|
if (j.st.open || restsOn(o, j, k) !== b.i) continue;
|
|
27607
27722
|
const q = o.parts[k];
|
|
27608
27723
|
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
27609
|
-
const
|
|
27724
|
+
const along3 = (c.min[fp.long] + c.max[fp.long]) / 2 - box5.min[fp.long];
|
|
27610
27725
|
const side = (c.min[across2] + c.max[across2]) / 2 - box5.min[across2];
|
|
27611
|
-
if (
|
|
27726
|
+
if (along3 >= vb.long[0] && along3 <= vb.long[1] && side >= vb.across[0] && side <= vb.across[1]) out.push({ q, j });
|
|
27612
27727
|
}
|
|
27613
27728
|
return out;
|
|
27614
27729
|
};
|
|
@@ -27826,7 +27941,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27826
27941
|
const units = q.spec.units?.size;
|
|
27827
27942
|
const step = units ? [Math.max(units[0], units[2]), units[1]] : [BRICK_STEP[0], BRICK_STEP[1]];
|
|
27828
27943
|
const reach2 = Math.hypot(toward2[0], toward2[2]) || 1;
|
|
27829
|
-
const
|
|
27944
|
+
const along3 = vec.normalize([toward2[0] / reach2, 1, toward2[2] / reach2]);
|
|
27830
27945
|
const width = clamp2(beta * SETTLEMENT_CRACK_OPENING, MIN_CRACK_WIDTH, MAX_CRACK_WIDTH);
|
|
27831
27946
|
const through = q.dims[q.thin];
|
|
27832
27947
|
for (let c = 0; c < count; c++) {
|
|
@@ -27834,7 +27949,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27834
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])];
|
|
27835
27950
|
const face = toLocal(q.pos, q.q, local2);
|
|
27836
27951
|
face[q.thin] = through / 2;
|
|
27837
|
-
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 });
|
|
27838
27953
|
}
|
|
27839
27954
|
if (beta >= damageAt && prior < damageAt) {
|
|
27840
27955
|
q.st.hp = Math.max(1, q.st.hp - q.st.maxHp * groundCfg.distortionDamage);
|
|
@@ -28041,6 +28156,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28041
28156
|
return turn2;
|
|
28042
28157
|
};
|
|
28043
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
|
+
};
|
|
28044
28182
|
const objectTurnBack = [0, 0, 0, 1];
|
|
28045
28183
|
const objectOrigin = [0, 0, 0];
|
|
28046
28184
|
const objectDirection = [0, 0, 0];
|
|
@@ -28164,21 +28302,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28164
28302
|
if (o.parts.length < PART_GRID_MIN_PARTS || !lo.every(Number.isFinite) || !ld.every(Number.isFinite)) return o.parts;
|
|
28165
28303
|
partGridOf(o).candidates(lo, ld, maxDist, gridCandidates);
|
|
28166
28304
|
gridParts.length = 0;
|
|
28167
|
-
for (
|
|
28305
|
+
for (let i = 0; i < gridCandidates.length; i++) gridParts.push(o.parts[gridCandidates[i]]);
|
|
28168
28306
|
return gridParts;
|
|
28169
28307
|
};
|
|
28170
28308
|
const splitInto = (o, cuts) => {
|
|
28171
|
-
const carryFor = (
|
|
28172
|
-
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 }])),
|
|
28173
28311
|
joints: new Map([
|
|
28174
|
-
...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 }]),
|
|
28175
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 }])
|
|
28176
28314
|
]),
|
|
28177
|
-
collapsed: [...o.collapsed].filter(
|
|
28315
|
+
collapsed: [...o.collapsed].filter(keep2),
|
|
28178
28316
|
cast: o.cast
|
|
28179
28317
|
});
|
|
28180
|
-
const sub2 = (
|
|
28181
|
-
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)) };
|
|
28182
28320
|
if (o.spec.tags) s.tags = [...o.spec.tags];
|
|
28183
28321
|
return s;
|
|
28184
28322
|
};
|
|
@@ -28203,6 +28341,28 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28203
28341
|
let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
|
|
28204
28342
|
const metObjects = [];
|
|
28205
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;
|
|
28206
28366
|
const candidatesOf2 = (hook) => {
|
|
28207
28367
|
const asked = hook.candidates;
|
|
28208
28368
|
if (!asked) return null;
|
|
@@ -28228,15 +28388,37 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28228
28388
|
}
|
|
28229
28389
|
return rayObjects;
|
|
28230
28390
|
};
|
|
28231
|
-
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip =
|
|
28232
|
-
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) => {
|
|
28233
28413
|
const asked = rayBroad && !scope2 && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
|
|
28234
28414
|
const candidates = asked ? candidatesOf2(asked) : null;
|
|
28235
28415
|
const outside = candidates ? null : asked;
|
|
28236
28416
|
const minRadius = skip.minObjectRadius ?? 0;
|
|
28237
28417
|
let best = null;
|
|
28238
28418
|
const counts = sweepCounts;
|
|
28239
|
-
|
|
28419
|
+
const visited = scope2 ? scope2.objects : candidates ?? objectsInOrder();
|
|
28420
|
+
for (let oi = 0; oi < visited.length; oi++) {
|
|
28421
|
+
const o = visited[oi];
|
|
28240
28422
|
if (counts) counts.objectVisits++;
|
|
28241
28423
|
if (skip.skipLoose && o.loose || o.br < minRadius) continue;
|
|
28242
28424
|
if (outside && !outside.mayMeet(o.id)) continue;
|
|
@@ -28251,7 +28433,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28251
28433
|
objectOrigin[2] = origin[2] - o.st.position[2];
|
|
28252
28434
|
const lo = rotateVecInto(objectTurnBack, objectOrigin, objectOrigin);
|
|
28253
28435
|
const ld = rotateVecInto(objectTurnBack, d, objectDirection);
|
|
28254
|
-
|
|
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];
|
|
28255
28439
|
if (counts) counts.partVisits++;
|
|
28256
28440
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
28257
28441
|
if (partSphereMiss(lo, ld, p, maxDist)) continue;
|
|
@@ -28293,18 +28477,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28293
28477
|
}
|
|
28294
28478
|
}
|
|
28295
28479
|
if (!best || r.t0 < best.distance) {
|
|
28296
|
-
|
|
28297
|
-
|
|
28298
|
-
|
|
28299
|
-
|
|
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
|
+
}
|
|
28300
28491
|
}
|
|
28301
28492
|
}
|
|
28302
28493
|
}
|
|
28303
|
-
|
|
28494
|
+
const hosted = worldOnly ? NO_IMPLS : scope2 ? scope2.impls : implsInOrder();
|
|
28495
|
+
for (let ii = 0; ii < hosted.length; ii++) {
|
|
28496
|
+
const im = hosted[ii];
|
|
28304
28497
|
if (counts) counts.objectVisits++;
|
|
28305
28498
|
if (!scope2 && broadPhase && rayMissesBounds(origin, d, maxDist, implBoundsOf(im))) continue;
|
|
28306
28499
|
let boxHit = null;
|
|
28307
|
-
|
|
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];
|
|
28308
28503
|
if (counts) counts.partVisits++;
|
|
28309
28504
|
if (ignore?.has(`${im.impl.id}\0${ps.id}`)) continue;
|
|
28310
28505
|
if (counts) {
|
|
@@ -28325,8 +28520,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28325
28520
|
const far = best ? Math.min(maxDist, best.distance) : maxDist;
|
|
28326
28521
|
const implId = im.impl.id;
|
|
28327
28522
|
const s = im.impl.surfaceRay({ origin, direction: d, maxDistance: far, ...ignore ? { ignored: (part) => ignore.has(`${implId}\0${part}`) } : {} });
|
|
28328
|
-
if (s && (!best || s.distance < best.distance)) best =
|
|
28329
|
-
} 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;
|
|
28330
28525
|
}
|
|
28331
28526
|
return best;
|
|
28332
28527
|
};
|
|
@@ -28790,8 +28985,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28790
28985
|
const dv = lp[v] - (ap.offset?.[1] ?? 0);
|
|
28791
28986
|
if (Math.abs(du) > ap.size[0] / 2 || Math.abs(dv) > ap.size[1] / 2) return false;
|
|
28792
28987
|
if (!ap.bars || ap.bars.spacing <= 0) return true;
|
|
28793
|
-
const
|
|
28794
|
-
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;
|
|
28795
28990
|
});
|
|
28796
28991
|
};
|
|
28797
28992
|
const breachAreaOf = (p, damage, blast) => damage / (p.mat.hpPerKg * p.mat.density) / Math.max(p.thickness, 5e-3) * (blast ? breachBlastFactor : 1);
|
|
@@ -29035,9 +29230,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29035
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);
|
|
29036
29231
|
const coreStands = (p, lp) => {
|
|
29037
29232
|
if (!p.spec.reinforcement || !isMember(p.dims, p.spec.structure?.role) || p.st.stripped) return false;
|
|
29038
|
-
const
|
|
29039
|
-
const bands = Math.max(1, Math.round(p.dims[
|
|
29040
|
-
const band = clamp2(Math.floor((lp[
|
|
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);
|
|
29041
29236
|
return (p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS;
|
|
29042
29237
|
};
|
|
29043
29238
|
const insideChip = (p, objectPoint) => {
|
|
@@ -29048,35 +29243,35 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29048
29243
|
if (coreStands(p, lp)) return false;
|
|
29049
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);
|
|
29050
29245
|
};
|
|
29051
|
-
const alongAt = (
|
|
29246
|
+
const alongAt = (along3, at4) => {
|
|
29052
29247
|
const point = [0, 0, 0];
|
|
29053
|
-
point[
|
|
29248
|
+
point[along3] = at4;
|
|
29054
29249
|
return point;
|
|
29055
29250
|
};
|
|
29056
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";
|
|
29057
29252
|
const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
|
|
29058
29253
|
var _a, _b, _c;
|
|
29059
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;
|
|
29060
|
-
const
|
|
29255
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
29061
29256
|
const lp = toLocal(p.pos, p.q, objLocal(o, entry2));
|
|
29062
29257
|
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
29063
29258
|
let depth = Infinity;
|
|
29064
|
-
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]));
|
|
29065
29260
|
if (!Number.isFinite(depth)) return true;
|
|
29066
29261
|
const into = (penMm ?? E / Math.max(p.mat.penetration, 1e-6)) / 1e3;
|
|
29067
29262
|
const h = Math.min(into, depth);
|
|
29068
29263
|
const r = Math.min(MEMBER_CRATER_CALIBRES * caliber / 1e3, h);
|
|
29069
29264
|
const volume = Math.PI / 3 * r * r * h;
|
|
29070
|
-
const section = p.dims.reduce((product2, size, a) => a ===
|
|
29071
|
-
const bands = Math.max(1, Math.round(p.dims[
|
|
29072
|
-
const band = clamp2(Math.floor((lp[
|
|
29073
|
-
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;
|
|
29074
29269
|
const worn = (_a = p.rt).bands ?? (_a.bands = {});
|
|
29075
29270
|
const before = worn[band] ?? 0;
|
|
29076
29271
|
const after2 = Math.min(1, before + volume / (section * height));
|
|
29077
29272
|
worn[band] = after2;
|
|
29078
29273
|
markDamaged(p);
|
|
29079
|
-
const bandCenter = -p.dims[
|
|
29274
|
+
const bandCenter = -p.dims[along3] / 2 + (band + 0.5) * height;
|
|
29080
29275
|
const grid = gridOf(p);
|
|
29081
29276
|
const gone = (_b = p.rt).chips ?? (_b.chips = {});
|
|
29082
29277
|
if (before >= MEMBER_CUT_LOSS || after2 < MEMBER_CUT_LOSS) {
|
|
@@ -29093,11 +29288,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29093
29288
|
const out = [];
|
|
29094
29289
|
for (let i = 0; i < grid.length; i++) {
|
|
29095
29290
|
if (gone[i] === -1) continue;
|
|
29096
|
-
if (Math.abs(grid[i].center[
|
|
29291
|
+
if (Math.abs(grid[i].center[along3] - bandCenter) <= height / 2 + 1e-6) out.push(i);
|
|
29097
29292
|
}
|
|
29098
29293
|
worn[band] = 1;
|
|
29099
29294
|
if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src, d);
|
|
29100
|
-
giveAtCut(o, p, src, { at: alongAt(
|
|
29295
|
+
giveAtCut(o, p, src, { at: alongAt(along3, bandCenter), d });
|
|
29101
29296
|
return true;
|
|
29102
29297
|
};
|
|
29103
29298
|
const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
|
|
@@ -29189,8 +29384,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29189
29384
|
const lo = cell.center[a] - cell.size[a] / 2, hi = cell.center[a] + cell.size[a] / 2;
|
|
29190
29385
|
const free = (side, sign2) => {
|
|
29191
29386
|
if (sign2 > 0 ? side >= half - 1e-6 : side <= -half + 1e-6) return sign2 > 0 || a !== planeAxes(p.thin)[1];
|
|
29192
|
-
const
|
|
29193
|
-
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);
|
|
29194
29389
|
};
|
|
29195
29390
|
if (at4 - lo <= reach2 && free(lo, -1)) return [lo, Math.max(crater2[1], lo)];
|
|
29196
29391
|
if (hi - at4 <= reach2 && free(hi, 1)) return [Math.min(crater2[0], hi), hi];
|
|
@@ -29484,19 +29679,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29484
29679
|
};
|
|
29485
29680
|
const cutBandsGone = (o, p, cells, d, src) => {
|
|
29486
29681
|
var _a;
|
|
29487
|
-
const
|
|
29488
|
-
const bands = Math.max(1, Math.round(p.dims[
|
|
29489
|
-
const height = p.dims[
|
|
29490
|
-
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);
|
|
29491
29686
|
const grid = gridOf(p);
|
|
29492
29687
|
const gone = p.rt.chips ?? {};
|
|
29493
29688
|
const worn = (_a = p.rt).bands ?? (_a.bands = {});
|
|
29494
|
-
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])))) {
|
|
29495
29690
|
if ((worn[band] ?? 0) >= 1) continue;
|
|
29496
|
-
const center = -p.dims[
|
|
29497
|
-
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;
|
|
29498
29693
|
worn[band] = 1;
|
|
29499
|
-
return giveAtCut(o, p, src, { at: alongAt(
|
|
29694
|
+
return giveAtCut(o, p, src, { at: alongAt(along3, center), d });
|
|
29500
29695
|
}
|
|
29501
29696
|
return false;
|
|
29502
29697
|
};
|
|
@@ -29541,14 +29736,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29541
29736
|
const r = p.spec.reinforcement;
|
|
29542
29737
|
if (!r) return 0;
|
|
29543
29738
|
const left = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length - (p.rt.severedBars?.length ?? 0);
|
|
29544
|
-
const
|
|
29545
|
-
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));
|
|
29546
29741
|
const fy = (materials.get(r.material)?.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
|
|
29547
29742
|
return Math.max(0, left) / 2 * Math.PI * (r.diameter / 2) ** 2 * fy * Math.max(0, side - 2 * REBAR_COVER);
|
|
29548
29743
|
};
|
|
29549
29744
|
const memberSide = (p) => {
|
|
29550
|
-
const
|
|
29551
|
-
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));
|
|
29552
29747
|
};
|
|
29553
29748
|
const tubeMoment = (p, share) => {
|
|
29554
29749
|
const [a = 0, b = 0] = [...p.dims].sort((x, y) => x - y);
|
|
@@ -29590,8 +29785,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29590
29785
|
const barAlong = (o, p, origin, d, t0, t1) => {
|
|
29591
29786
|
const r = p.spec.reinforcement;
|
|
29592
29787
|
if (!r || !isMember(p.dims, p.spec.structure?.role)) return null;
|
|
29593
|
-
const
|
|
29594
|
-
const [u, v] = [0, 1, 2].filter((k) => k !==
|
|
29788
|
+
const along3 = p.dims.indexOf(Math.max(...p.dims));
|
|
29789
|
+
const [u, v] = [0, 1, 2].filter((k) => k !== along3);
|
|
29595
29790
|
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
29596
29791
|
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
29597
29792
|
const across2 = Math.hypot(ld[u], ld[v]);
|
|
@@ -29640,8 +29835,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29640
29835
|
var _a;
|
|
29641
29836
|
const r = p.spec.reinforcement;
|
|
29642
29837
|
if (!r || isLost(p) || !isMember(p.dims, p.spec.structure?.role)) return;
|
|
29643
|
-
const
|
|
29644
|
-
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);
|
|
29645
29840
|
const lo = toLocal(p.pos, p.q, objLocal(o, origin));
|
|
29646
29841
|
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
29647
29842
|
const across2 = Math.hypot(ld[u], ld[v]);
|
|
@@ -29752,7 +29947,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29752
29947
|
const hitLocal = toLocal(c, q, hitW);
|
|
29753
29948
|
const unitPlan = p.spec.units ? unitFragmentPlan(p, maxFragments * UNIT_FRAGMENT_FACTOR) : [];
|
|
29754
29949
|
const axis2 = style === "splinter" || style === "snap" ? severAxis(p) : -1;
|
|
29755
|
-
const
|
|
29950
|
+
const cutAt3 = axis2 < 0 ? void 0 : p.rt.cutAt ?? (origin ? hitLocal[axis2] : void 0);
|
|
29756
29951
|
const planRnd = p.mat.splitForm ? splitStream(o.id, p.spec.id, hitLocal) : rnd2;
|
|
29757
29952
|
const plan = unitPlan.length > 0 ? unitPlan : planFragments({
|
|
29758
29953
|
style,
|
|
@@ -29765,7 +29960,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29765
29960
|
rnd: planRnd,
|
|
29766
29961
|
sheet: p.mat.sheet,
|
|
29767
29962
|
...p.mat.splitForm ? { form: p.mat.splitForm } : {},
|
|
29768
|
-
...
|
|
29963
|
+
...cutAt3 !== void 0 ? { cut: { at: cutAt3, gap: SEVER_BAND } } : {},
|
|
29769
29964
|
...p.spec.solids ? { solids: p.spec.solids } : {}
|
|
29770
29965
|
});
|
|
29771
29966
|
const holes = p.st.holes.length > 0 ? localHolesOf(p) : [];
|
|
@@ -29842,9 +30037,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29842
30037
|
};
|
|
29843
30038
|
const bandOf = (o, p, axis2, origin) => {
|
|
29844
30039
|
const { c, q } = partXf(o, p);
|
|
29845
|
-
const
|
|
30040
|
+
const along3 = toLocal(c, q, origin)[axis2];
|
|
29846
30041
|
const L = p.dims[axis2];
|
|
29847
|
-
return clamp2(Math.floor((
|
|
30042
|
+
return clamp2(Math.floor((along3 + L / 2) / SEVER_BAND), 0, Math.ceil(L / SEVER_BAND) - 1);
|
|
29848
30043
|
};
|
|
29849
30044
|
const applyDamage = (o, p, amount, type, origin, dir, fragEnergy, cap, src, weight = 1, section = 1) => {
|
|
29850
30045
|
var _a;
|
|
@@ -29913,7 +30108,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29913
30108
|
const fibre = tear === "lumps";
|
|
29914
30109
|
const strips = tear === "strips";
|
|
29915
30110
|
const { q } = partXf(o, p);
|
|
29916
|
-
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];
|
|
29917
30112
|
const fragments = [];
|
|
29918
30113
|
for (let i = 0; i < n; i++) {
|
|
29919
30114
|
const back2 = !exit || i % 3 === 2;
|
|
@@ -29921,9 +30116,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29921
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());
|
|
29922
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());
|
|
29923
30118
|
const size = [w, w, w];
|
|
29924
|
-
size[
|
|
29925
|
-
size[(
|
|
29926
|
-
size[(
|
|
30119
|
+
size[along3] = len;
|
|
30120
|
+
size[(along3 + 1) % 3] = w;
|
|
30121
|
+
size[(along3 + 2) % 3] = t;
|
|
29927
30122
|
const spread3 = [(rnd2() - 0.5) * 0.8, (rnd2() - 0.2) * 0.8, (rnd2() - 0.5) * 0.8];
|
|
29928
30123
|
const speed = shot ? back2 ? 1.5 + 2 * rnd2() : 2 + 4 * rnd2() : 0.8 + 1.2 * rnd2();
|
|
29929
30124
|
const v = vec.scale(vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3)), speed);
|
|
@@ -30063,8 +30258,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30063
30258
|
j.st.open = true;
|
|
30064
30259
|
j.st.openedBy = "break";
|
|
30065
30260
|
}
|
|
30066
|
-
const
|
|
30067
|
-
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);
|
|
30068
30263
|
loosened(o, opened, "break", src);
|
|
30069
30264
|
collapseCheck(o, src);
|
|
30070
30265
|
};
|
|
@@ -30427,7 +30622,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30427
30622
|
if (!r?.part) continue;
|
|
30428
30623
|
reportShelter(o, r);
|
|
30429
30624
|
out.push(r);
|
|
30430
|
-
for (const [part,
|
|
30625
|
+
for (const [part, factor2] of Object.entries(r.blast?.parts ?? {})) summary2.push({ object: o.id, part, factor: factor2 });
|
|
30431
30626
|
fragmentHits += r.blast?.fragmentHits ?? 0;
|
|
30432
30627
|
}
|
|
30433
30628
|
for (const im of impls.values()) {
|
|
@@ -30554,8 +30749,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30554
30749
|
const lineMeetsSphere = (t, point, d, range3) => {
|
|
30555
30750
|
if (t.distance - t.radius >= range3) return false;
|
|
30556
30751
|
if (t.distance <= t.radius) return true;
|
|
30557
|
-
const
|
|
30558
|
-
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;
|
|
30559
30754
|
};
|
|
30560
30755
|
const boxDirection = [0, 0, 0];
|
|
30561
30756
|
const lineMeetsBox = (box5, d, range3) => {
|
|
@@ -31314,6 +31509,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31314
31509
|
finishExplosions();
|
|
31315
31510
|
const id = opts.id ?? impl.id;
|
|
31316
31511
|
if (taken(id)) throw new Error(`object "${id}" already exists`);
|
|
31512
|
+
implsRevision++;
|
|
31317
31513
|
impls.set(id, { impl, position: opts.position ?? [0, 0, 0], rotation: opts.rotation ?? [0, 0, 0, 1], poses: /* @__PURE__ */ new Map(), posesVersion: 0 });
|
|
31318
31514
|
return id;
|
|
31319
31515
|
},
|
|
@@ -31344,6 +31540,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31344
31540
|
if (existing) dirtyHosted.delete(existing);
|
|
31345
31541
|
dropObject(id);
|
|
31346
31542
|
impls.delete(id);
|
|
31543
|
+
implsRevision++;
|
|
31347
31544
|
},
|
|
31348
31545
|
has: (id) => taken(id),
|
|
31349
31546
|
ids: () => [...objects.keys(), ...impls.keys()],
|
|
@@ -31479,6 +31676,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31479
31676
|
const terrain = objects.get(r.object)?.parts.find((p) => p.spec.id === r.part)?.spec.tags?.includes("terrain") === true;
|
|
31480
31677
|
return { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: r.distance, ...terrain ? { terrain: true } : {} };
|
|
31481
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
|
+
},
|
|
31482
31702
|
sweepBox(box5, direction, distance4, options2 = {}) {
|
|
31483
31703
|
const d = vec.normalize(direction);
|
|
31484
31704
|
const ignoredIds = options2.ignore === void 0 ? [] : typeof options2.ignore === "string" ? [options2.ignore] : options2.ignore;
|
|
@@ -31737,7 +31957,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31737
31957
|
...p.spec.shape.kind === "cylinder" ? { round: true } : {}
|
|
31738
31958
|
}));
|
|
31739
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 }));
|
|
31740
|
-
return assemblyFlex({ parts: parts2, joints, lost: [...lost], ...options2?.loads ? { loads: options2.loads } : {}, ...options2?.friction !== void 0 ? { friction: options2.friction } : {} });
|
|
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 } : {} });
|
|
31741
31961
|
},
|
|
31742
31962
|
reset(id) {
|
|
31743
31963
|
finishExplosions();
|
|
@@ -32058,17 +32278,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32058
32278
|
return new Map(w.state(id).parts.map((p) => [p.id, p.flexure ?? 0]));
|
|
32059
32279
|
};
|
|
32060
32280
|
const base2 = bending(out);
|
|
32061
|
-
const
|
|
32281
|
+
const factor2 = new Map(targets.map((p) => [p.id, (base2.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
|
|
32062
32282
|
if (options.redundancy !== void 0) {
|
|
32063
32283
|
const roles = options.redundancyRoles ?? ["column"];
|
|
32064
32284
|
for (const lost of out.parts) {
|
|
32065
32285
|
if (!lost.structure || !roles.includes(lost.structure.role)) continue;
|
|
32066
32286
|
const l = bending(without(out, lost.id));
|
|
32067
|
-
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));
|
|
32068
32288
|
}
|
|
32069
32289
|
}
|
|
32070
32290
|
for (const p of targets) {
|
|
32071
|
-
const f =
|
|
32291
|
+
const f = factor2.get(p.id);
|
|
32072
32292
|
const g = bendGeometry(p);
|
|
32073
32293
|
if (f <= 1 || g.gravity < 0) continue;
|
|
32074
32294
|
const section = { b: sectionWidth(g, g.gravity), h: g.dims[g.gravity] };
|
|
@@ -32886,19 +33106,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32886
33106
|
const padded = holds2(line, 0.02, wall.aabb);
|
|
32887
33107
|
if (!padded) continue;
|
|
32888
33108
|
const reach2 = context.section.along / 2;
|
|
32889
|
-
const
|
|
32890
|
-
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;
|
|
32891
33111
|
const alongU = wall.aabb[2] - wall.aabb[0] >= wall.aabb[3] - wall.aabb[1];
|
|
32892
33112
|
const openings = context.structure.openings.filter((o) => o.wall === wall.id);
|
|
32893
33113
|
if (line.dir === "u" === alongU) {
|
|
32894
|
-
let pieces = [
|
|
33114
|
+
let pieces = [along3];
|
|
32895
33115
|
for (const o of openings) {
|
|
32896
33116
|
const a = o.from - line.from - JAMB_CLEAR - reach2;
|
|
32897
33117
|
const b = o.to - line.from + JAMB_CLEAR + reach2;
|
|
32898
33118
|
pieces = pieces.flatMap(([x, y]) => b <= x || a >= y ? [[x, y]] : [[x, a], [b, y]].filter(([p, q]) => q > p));
|
|
32899
33119
|
}
|
|
32900
33120
|
out.push(...pieces);
|
|
32901
|
-
} 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);
|
|
32902
33122
|
}
|
|
32903
33123
|
const bottom = context.structure.levels[floor2] ?? 0;
|
|
32904
33124
|
const half = context.section.along / 2;
|
|
@@ -33412,9 +33632,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
33412
33632
|
const capacity = input.capacities.get(id);
|
|
33413
33633
|
capacities.delete(id);
|
|
33414
33634
|
if (capacity === void 0) continue;
|
|
33415
|
-
const
|
|
33416
|
-
const length2 =
|
|
33417
|
-
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));
|
|
33418
33638
|
}
|
|
33419
33639
|
return { ...next, capacities };
|
|
33420
33640
|
}
|
|
@@ -33430,14 +33650,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
33430
33650
|
const size = part.shape.size;
|
|
33431
33651
|
const thin = size.indexOf(Math.min(...size));
|
|
33432
33652
|
if (thin === 1) return [];
|
|
33433
|
-
const [
|
|
33653
|
+
const [along3] = planeAxes2(thin);
|
|
33434
33654
|
const turn2 = part.rotation?.[1] ?? 0;
|
|
33435
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];
|
|
33436
33656
|
return windows.map((opening2) => {
|
|
33437
33657
|
const middle = (opening2.from + opening2.to) / 2;
|
|
33438
33658
|
const centre2 = alongU ? [middle, (opening2.y0 + opening2.y1) / 2, part.position[2]] : [part.position[0], (opening2.y0 + opening2.y1) / 2, middle];
|
|
33439
33659
|
const local2 = toPartFrame(part, centre2);
|
|
33440
|
-
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]] };
|
|
33441
33661
|
});
|
|
33442
33662
|
}
|
|
33443
33663
|
function withWindowApertures(spec, openings) {
|
|
@@ -33764,12 +33984,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
33764
33984
|
parts2.push({ id, material: c.material, shape: box2(size), position, structure: { role: "partition" }, tags: ["infill"] });
|
|
33765
33985
|
for (const o of on) rests(joints, id, o, "mortar");
|
|
33766
33986
|
};
|
|
33767
|
-
const bay = (side, k,
|
|
33987
|
+
const bay = (side, k, along3, centre2, fixed2, length2, c1, c2) => {
|
|
33768
33988
|
const clear = length2 - g.columnSize;
|
|
33769
33989
|
const win = clear * c.window;
|
|
33770
33990
|
const pier = (clear - win) / 2;
|
|
33771
|
-
const at23 = (u) =>
|
|
33772
|
-
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];
|
|
33773
33993
|
const put = (name, u, h, y, centreU, on) => {
|
|
33774
33994
|
const p = at23(centreU);
|
|
33775
33995
|
wall(`infill_${f}_${side}_${k}_${name}`, size(u, h), [p[0], y, p[2]], on);
|
|
@@ -34079,8 +34299,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
34079
34299
|
const ti = given2.innerThickness ?? CORE_DEFAULTS.innerThickness;
|
|
34080
34300
|
const shaft = given2.shaft ?? CORE_DEFAULTS.shaft;
|
|
34081
34301
|
const fit = Math.max(1, Math.floor((bay[1] - 2 * CORE_CLEARANCE - 0.2 - 2 * wallThickness + ti) / (shaft + ti)));
|
|
34082
|
-
const
|
|
34083
|
-
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)));
|
|
34084
34304
|
const elevators = Math.max(1, Math.min(wanted, fit));
|
|
34085
34305
|
const narrow = coreSize({ ...given2, wallThickness, elevators });
|
|
34086
34306
|
const room = bay[0] - columnSize - 2 * CORE_CLEARANCE - narrow[0];
|
|
@@ -56316,7 +56536,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
56316
56536
|
}
|
|
56317
56537
|
for (const e of planned.items) if (e.type === "lantern_lamp") e.item.on = !!e.lit;
|
|
56318
56538
|
let scratch3 = null;
|
|
56319
|
-
function
|
|
56539
|
+
function probe2(e, hinge, setback, blockedAt) {
|
|
56320
56540
|
if (!scratch3) scratch3 = GI.createWorld({ locale, strings: hh.strings, items: hh.items, loot: hh.loot, grid: false });
|
|
56321
56541
|
const it = at(e.item);
|
|
56322
56542
|
const x = it.x + Math.sin(it.ry) * setback;
|
|
@@ -56340,12 +56560,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
56340
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;
|
|
56341
56561
|
function fitDoors(e) {
|
|
56342
56562
|
if (!isBlocked2 || !householdTypes.has(e.type)) return;
|
|
56343
|
-
const standard =
|
|
56563
|
+
const standard = probe2(e, void 0, 0, isBlocked2);
|
|
56344
56564
|
if (!standard.n || standard.min >= 1) return;
|
|
56345
56565
|
let bestSide;
|
|
56346
56566
|
let m = standard;
|
|
56347
56567
|
for (const side of ["left", "right"]) {
|
|
56348
|
-
const r =
|
|
56568
|
+
const r = probe2(e, side, 0, isBlocked2);
|
|
56349
56569
|
if (better(r, m)) {
|
|
56350
56570
|
m = r;
|
|
56351
56571
|
bestSide = side;
|
|
@@ -56358,7 +56578,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
56358
56578
|
if (m.min >= 1) return;
|
|
56359
56579
|
let target = { setback: 0, r: m };
|
|
56360
56580
|
for (const setback of [0.01, 0.02, 0.03, 0.04]) {
|
|
56361
|
-
const r =
|
|
56581
|
+
const r = probe2(e, bestSide, setback, isBlocked2);
|
|
56362
56582
|
if (better(r, target.r)) target = { setback, r };
|
|
56363
56583
|
if (r.min >= 1) break;
|
|
56364
56584
|
}
|
|
@@ -58954,12 +59174,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58954
59174
|
if (p.blocked) {
|
|
58955
59175
|
part("window_boards", [0, 0, 0], () => {
|
|
58956
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];
|
|
58957
|
-
const puts = (
|
|
58958
|
-
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;
|
|
58959
59179
|
boxC("wood", x, y0 + y, z, comp, alt, thickness, color2, 0, alongU ? 0 : K.PE, tilt);
|
|
58960
59180
|
};
|
|
58961
|
-
const nailColor = (
|
|
58962
|
-
const x = alongU ?
|
|
59181
|
+
const nailColor = (along22, y, off) => {
|
|
59182
|
+
const x = alongU ? along22 : L + off, z = alongU ? L + off : along22;
|
|
58963
59183
|
boxC("metal", x, y0 + y, z, alongU ? 0.022 : 0.016, 0.022, alongU ? 0.016 : 0.022, 3815478);
|
|
58964
59184
|
};
|
|
58965
59185
|
for (const sd of [-1, 1]) {
|
|
@@ -59415,8 +59635,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
59415
59635
|
};
|
|
59416
59636
|
const underCovering = (items, x, z, y) => items.some((o) => {
|
|
59417
59637
|
if (o.type !== "blinds" && o.type !== "curtain") return false;
|
|
59418
|
-
const co = Math.cos(o.ry || 0), si = Math.sin(o.ry || 0), dx = x - o.x, dz = z - o.z,
|
|
59419
|
-
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;
|
|
59420
59640
|
});
|
|
59421
59641
|
for (const c of R.rooms) {
|
|
59422
59642
|
if (c.type === "void" || OPEN_AREA(c)) continue;
|
|
@@ -60091,9 +60311,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60091
60311
|
const x0 = xs[i], x1 = xs[i + 1], z0 = zs[j], z1 = zs[j + 1], yb = pe(x0, z0, x1, z1);
|
|
60092
60312
|
cursor.pc = K.panelAt("slab_top", (x0 + x1) / 2, (z0 + z1) / 2);
|
|
60093
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;
|
|
60094
|
-
const
|
|
60314
|
+
const keep2 = !shared3.ctx.visorScene, parapet = [];
|
|
60095
60315
|
const lay = (box5, color2, taken) => {
|
|
60096
|
-
if (!
|
|
60316
|
+
if (!keep2 || !taken.length) {
|
|
60097
60317
|
bx("plaster", box5[0], box5[1], box5[2], box5[3], box5[4], box5[5], color2);
|
|
60098
60318
|
return;
|
|
60099
60319
|
}
|
|
@@ -60109,7 +60329,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60109
60329
|
for (const [ok, ax0, az0, ax1, az1] of sides) if (ok) parapet.push([ax0, yb, az0, ax1, yb + pr, az1]);
|
|
60110
60330
|
lay([x0 - ex0, yb, z0 - ez0, x1 + ex1, yb + 0.03, z1 + ez1], slab, parapet);
|
|
60111
60331
|
{
|
|
60112
|
-
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 : [];
|
|
60113
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);
|
|
60114
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);
|
|
60115
60335
|
if (free(j - 1, i)) lay([x0, yc, z0 - wt, x1, yb, z0], c, under);
|
|
@@ -60197,8 +60417,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
60197
60417
|
ex /= el;
|
|
60198
60418
|
ey /= el;
|
|
60199
60419
|
ez /= el;
|
|
60200
|
-
const aligned = !shared3.ctx.visorScene,
|
|
60201
|
-
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 = [];
|
|
60202
60422
|
for (const p of pts) {
|
|
60203
60423
|
const rx = p[0] - o[0], ry = p[1] - o[1], rz = p[2] - o[2];
|
|
60204
60424
|
S.push(rx * ex + ry * ey + rz * ez);
|
|
@@ -61061,10 +61281,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61061
61281
|
if (opening.floor > floor2 || opening.y1 === void 0) return false;
|
|
61062
61282
|
return (plan.floors[opening.floor]?.y0 ?? 0) + opening.y1 > (plan.floors[floor2]?.y0 ?? 0);
|
|
61063
61283
|
}
|
|
61064
|
-
function clearOfOpenings(plan, wall,
|
|
61284
|
+
function clearOfOpenings(plan, wall, along22, endClear = DEFAULT_END_CLEAR) {
|
|
61065
61285
|
const line = wall.axis === "u" ? wall.v0 : wall.u0;
|
|
61066
61286
|
const a0 = wall.axis === "u" ? wall.u0 : wall.v0, a1 = wall.axis === "u" ? wall.u1 : wall.v1;
|
|
61067
|
-
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;
|
|
61068
61288
|
for (const o of plan.openings) {
|
|
61069
61289
|
if (o.axis !== wall.axis || Math.abs(o.pos - line) > 0.05 || !reaches(plan, o, wall.floor)) continue;
|
|
61070
61290
|
const lo = o.at - o.width / 2 - OPENING_CLEARANCE, hi = o.at + o.width / 2 + OPENING_CLEARANCE;
|
|
@@ -61086,7 +61306,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61086
61306
|
if (!best) return null;
|
|
61087
61307
|
const { wall } = best;
|
|
61088
61308
|
const alongU = wall.axis === "u";
|
|
61089
|
-
const
|
|
61309
|
+
const along22 = clearOfOpenings(plan, wall, best.along, options.endClear);
|
|
61090
61310
|
const line = alongU ? wall.v0 : wall.u0;
|
|
61091
61311
|
const [ru, rv] = options.toward ?? [u, v];
|
|
61092
61312
|
const across2 = alongU ? rv - line : ru - line;
|
|
@@ -61096,7 +61316,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61096
61316
|
const half = (wall.thickness ?? DEFAULT_THICKNESS) / 2;
|
|
61097
61317
|
const offset = options.surface ? half + (options.diameter ?? 0.02) / 2 : half - chaseDepth(options.diameter);
|
|
61098
61318
|
const at4 = line + side * offset;
|
|
61099
|
-
return { u: alongU ?
|
|
61319
|
+
return { u: alongU ? along22 : at4, v: alongU ? at4 : along22, wall };
|
|
61100
61320
|
}
|
|
61101
61321
|
function buildingBox(plan, wall) {
|
|
61102
61322
|
if (!wall.outbuilding) return houseFootprint(plan);
|
|
@@ -61121,8 +61341,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61121
61341
|
const start = alongU ? first.u : first.v;
|
|
61122
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)];
|
|
61123
61343
|
let fallback2 = null;
|
|
61124
|
-
for (const
|
|
61125
|
-
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)) });
|
|
61126
61346
|
if (!exit) continue;
|
|
61127
61347
|
for (const turnFirst of [false, true]) {
|
|
61128
61348
|
const feed = feedFrom(plan, exit, target, y, { ...options, turnFirst });
|
|
@@ -61342,10 +61562,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61342
61562
|
const y = rise(s) * Math.pow(Math.max(0, Math.sin(Math.PI * t / width)), 0.8) - MOUND_SINK;
|
|
61343
61563
|
return alongX ? [x0 + s, y, z0 + t] : [x0 + t, y, z0 + s];
|
|
61344
61564
|
};
|
|
61345
|
-
const
|
|
61346
|
-
for (let i = 0; i <
|
|
61565
|
+
const along22 = MOUND_GRID.along * humps, { across: across2 } = MOUND_GRID;
|
|
61566
|
+
for (let i = 0; i < along22; i++) {
|
|
61347
61567
|
for (let j = 0; j < across2; j++) {
|
|
61348
|
-
const s0 = length2 * i /
|
|
61568
|
+
const s0 = length2 * i / along22, s1 = length2 * (i + 1) / along22, t0 = width * j / across2, t1 = width * (j + 1) / across2;
|
|
61349
61569
|
const quad = [at4(s0, t0), at4(s1, t0), at4(s1, t1), at4(s0, t1)];
|
|
61350
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]];
|
|
61351
61571
|
const up = e1[2] * e2[0] - e1[0] * e2[2];
|
|
@@ -61763,9 +61983,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61763
61983
|
}
|
|
61764
61984
|
var CAP_SINK = 2e-3;
|
|
61765
61985
|
function drawnEnds(span, previous, next) {
|
|
61766
|
-
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];
|
|
61767
61987
|
const shift = (neighbour) => span.host !== null ? -CAP_SINK : neighbour && neighbour.host !== null ? CAP_SINK : 0;
|
|
61768
|
-
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];
|
|
61769
61989
|
return span.length > 4 * CAP_SINK ? [move2(span.a, -shift(previous)), move2(span.b, shift(next))] : [span.a, span.b];
|
|
61770
61990
|
}
|
|
61771
61991
|
var PIPE_WALL_FILL = 0.3;
|
|
@@ -62342,11 +62562,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
62342
62562
|
function chasesIn(wall, core, runs) {
|
|
62343
62563
|
const out = [];
|
|
62344
62564
|
for (const r of runs) {
|
|
62345
|
-
const
|
|
62346
|
-
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;
|
|
62347
62567
|
if (Math.abs(across2) > wall.thickness / 2 + 1e-6) continue;
|
|
62348
62568
|
const back2 = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
|
|
62349
|
-
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 } : {} });
|
|
62350
62570
|
}
|
|
62351
62571
|
return out;
|
|
62352
62572
|
}
|
|
@@ -62367,11 +62587,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
62367
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]))];
|
|
62368
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));
|
|
62369
62589
|
if (!under.length) continue;
|
|
62370
|
-
const
|
|
62590
|
+
const along22 = (alongU) => {
|
|
62371
62591
|
const own2 = under.filter((c) => beams.includes(c) && c.aabb[2] - c.aabb[0] >= c.aabb[3] - c.aabb[1] === alongU);
|
|
62372
62592
|
return own2.length ? own2 : under;
|
|
62373
62593
|
};
|
|
62374
|
-
const [acrossU, acrossV] = [
|
|
62594
|
+
const [acrossU, acrossV] = [along22(false), along22(true)];
|
|
62375
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]))];
|
|
62376
62596
|
for (const s of own) {
|
|
62377
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;
|
|
@@ -62631,7 +62851,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
62631
62851
|
const alongHalf = (span + size.holderAlong) / 2 + size.battenOverhang;
|
|
62632
62852
|
const across2 = size.battenWidth / 2;
|
|
62633
62853
|
const battenBase = mountY - size.battenHeight;
|
|
62634
|
-
const around = (
|
|
62854
|
+
const around = (along22, cross5) => alongU ? [x + along22, z + cross5] : [x + cross5, z + along22];
|
|
62635
62855
|
const rectangle = (along0, along1, cross0, cross1, y0, y1, color2) => {
|
|
62636
62856
|
const [ax, az] = around(along0, cross0);
|
|
62637
62857
|
const [bx, bz] = around(along1, cross1);
|
|
@@ -62684,7 +62904,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
62684
62904
|
function wallBehindOf(walls, point) {
|
|
62685
62905
|
const alongU = Math.abs(point.frontV) >= Math.abs(point.frontU);
|
|
62686
62906
|
const across2 = alongU ? point.v : point.u;
|
|
62687
|
-
const
|
|
62907
|
+
const along22 = alongU ? point.u : point.v;
|
|
62688
62908
|
let best;
|
|
62689
62909
|
let bestGap = Infinity;
|
|
62690
62910
|
for (const wall of walls) {
|
|
@@ -62692,7 +62912,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
62692
62912
|
const line = alongU ? wall.v0 : wall.u0;
|
|
62693
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)];
|
|
62694
62914
|
const gap = Math.abs(across2 - line);
|
|
62695
|
-
if (
|
|
62915
|
+
if (along22 < from - 1e-6 || along22 > to + 1e-6 || gap > wall.thickness || gap >= bestGap) continue;
|
|
62696
62916
|
best = { line, halfThickness: wall.thickness / 2 };
|
|
62697
62917
|
bestGap = gap;
|
|
62698
62918
|
}
|
|
@@ -67379,8 +67599,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67379
67599
|
for (const part of parts2) {
|
|
67380
67600
|
const boxes = part.gone?.length ? subtract2(mergeSpans(part.spans), part.gone) : mergeSpans(part.spans);
|
|
67381
67601
|
for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
|
|
67382
|
-
const
|
|
67383
|
-
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);
|
|
67384
67604
|
const length2 = (s.b - s.a) / 2, up = (s.y1 - s.y0) / 2, across2 = part.thick / 2;
|
|
67385
67605
|
out.push({
|
|
67386
67606
|
center: [point.x, point.y, point.z],
|
|
@@ -67857,13 +68077,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67857
68077
|
}
|
|
67858
68078
|
function splitUnits(view, id, around) {
|
|
67859
68079
|
const { mask } = view;
|
|
67860
|
-
const
|
|
68080
|
+
const along22 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
|
|
67861
68081
|
const part = structure.byId.get(id), units = specOf(id).units, chips2 = view.chips.get(id), opening = view.openings.get(id);
|
|
67862
68082
|
const own = cells(part, units, mask);
|
|
67863
68083
|
const all = (id === view.host ? own.flatMap((c) => besidePillars(c, around.pillars)) : own).flatMap((c) => outsideGaps(c, around.gaps));
|
|
67864
68084
|
const holes = [], kept = [];
|
|
67865
68085
|
if (view.fallen.has(id)) return { all, kept, holes: all, boxes: [] };
|
|
67866
|
-
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 }));
|
|
67867
68087
|
const gone = (c) => {
|
|
67868
68088
|
const over = boxes.filter((k) => k.s1 > c.a && k.s0 < c.b && k.y1 > c.y0 && k.y0 < c.y1);
|
|
67869
68089
|
const share = covered(c, over);
|
|
@@ -67871,7 +68091,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67871
68091
|
const s = (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2;
|
|
67872
68092
|
return share >= 0.5 && over.some((k) => s >= k.s0 && s <= k.s1 && y >= k.y0 && y <= k.y1);
|
|
67873
68093
|
};
|
|
67874
|
-
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;
|
|
67875
68095
|
for (const c of all) (open(c) ? holes : kept).push(c);
|
|
67876
68096
|
return { all, kept, holes, boxes };
|
|
67877
68097
|
}
|
|
@@ -67884,12 +68104,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67884
68104
|
function publishStanding(view) {
|
|
67885
68105
|
if (!view.saved) return;
|
|
67886
68106
|
const { mask } = view;
|
|
67887
|
-
const
|
|
68107
|
+
const along22 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
|
|
67888
68108
|
const parts2 = view.parts.map((id) => {
|
|
67889
68109
|
const part = structure.byId.get(id);
|
|
67890
68110
|
const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
|
|
67891
68111
|
const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
|
|
67892
|
-
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 }));
|
|
67893
68113
|
return { spans: view.kept.get(id) ?? [], gone, thick, mid };
|
|
67894
68114
|
});
|
|
67895
68115
|
const line = { alongU: mask.alongU, start: mask.start, open: view.core };
|
|
@@ -67897,7 +68117,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67897
68117
|
}
|
|
67898
68118
|
function paint2(view) {
|
|
67899
68119
|
const { mask, core } = view;
|
|
67900
|
-
const
|
|
68120
|
+
const along22 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
|
|
67901
68121
|
const holes = [];
|
|
67902
68122
|
const pits = [];
|
|
67903
68123
|
const discs = [];
|
|
@@ -67915,8 +68135,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67915
68135
|
}
|
|
67916
68136
|
const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
|
|
67917
68137
|
const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
|
|
67918
|
-
if (opening) discs.push({ s:
|
|
67919
|
-
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 });
|
|
67920
68140
|
holes.push(...lost);
|
|
67921
68141
|
view.kept.set(id, kept);
|
|
67922
68142
|
if (units2.mortar === part.material) {
|
|
@@ -69421,8 +69641,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69421
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]];
|
|
69422
69642
|
const ridgeTop = TIMBER.purlin.top;
|
|
69423
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));
|
|
69424
|
-
const
|
|
69425
|
-
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));
|
|
69426
69646
|
for (let j = 0; j <= posts; j++) {
|
|
69427
69647
|
const f = posts ? j / posts : 0;
|
|
69428
69648
|
const x = ends[0][0] + (ends[1][0] - ends[0][0]) * f, z = ends[0][2] + (ends[1][2] - ends[0][2]) * f;
|
|
@@ -77833,9 +78053,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
77833
78053
|
};
|
|
77834
78054
|
var fitLength = (kit, inner, lengthMetres) => {
|
|
77835
78055
|
const box5 = new kit.THREE.Box3().setFromObject(inner);
|
|
77836
|
-
const
|
|
77837
|
-
inner.scale.x =
|
|
77838
|
-
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;
|
|
77839
78059
|
const root = kit.group();
|
|
77840
78060
|
root.add(inner);
|
|
77841
78061
|
return root;
|
|
@@ -84622,9 +84842,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
84622
84842
|
} else hip.set(side * NO_GRIP_REAR[0], NO_GRIP_REAR[1], NO_GRIP_REAR[2] + box5.min.x);
|
|
84623
84843
|
const k = ease(Math.max(0, Math.min(1, placement.aim)));
|
|
84624
84844
|
if (k > 0) {
|
|
84625
|
-
const
|
|
84845
|
+
const along3 = box5.min.x + hold.sights.fromRear;
|
|
84626
84846
|
scratch2.aimed ?? (scratch2.aimed = new THREE.Vector3());
|
|
84627
|
-
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);
|
|
84628
84848
|
}
|
|
84629
84849
|
holder.position.copy(hip).add(placement.offset);
|
|
84630
84850
|
hand.updateMatrixWorld(true);
|
|
@@ -88018,8 +88238,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
88018
88238
|
const end3 = CURVE[CURVE.length - 1];
|
|
88019
88239
|
const before = CURVE[CURVE.length - 2];
|
|
88020
88240
|
const angle = Math.atan2(end3[1] - before[1], end3[0] - before[0]);
|
|
88021
|
-
const
|
|
88022
|
-
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]));
|
|
88023
88243
|
const { bar: bar2, chisel } = shapesOf(T2, extrude2);
|
|
88024
88244
|
return G(mesh3(bar2, forged), mesh3(chisel, steel), ...prongs);
|
|
88025
88245
|
};
|
|
@@ -88749,15 +88969,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
88749
88969
|
return G(lower, stripe, upper, topCrimp, bottomCrimp, label, drop);
|
|
88750
88970
|
};
|
|
88751
88971
|
var syringe = ({ mesh: mesh3, bx, cyl, G, plastic, metal: metal2, glass }) => {
|
|
88752
|
-
const
|
|
88972
|
+
const along3 = [0, 0, Math.PI / 2];
|
|
88753
88973
|
const alongTip = [0, 0, -Math.PI / 2];
|
|
88754
|
-
const barrel = mesh3(cyl(0.075, 0.075, 0.7, 10), glass(13625584, 0.55), [-0.1, 0, 0],
|
|
88755
|
-
const flange = mesh3(cyl(0.1, 0.1, 0.025, 12), plastic(15265520), [-0.45, 0, 0],
|
|
88756
|
-
const stopper = mesh3(cyl(0.07, 0.07, 0.07, 8), plastic(2829099), [-0.3, 0, 0],
|
|
88757
|
-
const rod = mesh3(cyl(0.022, 0.022, 0.5, 6), plastic(15265520), [-0.475, 0, 0],
|
|
88758
|
-
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);
|
|
88759
88979
|
const hub = mesh3(cyl(0.025, 0.06, 0.1, 8), plastic(15790320), [0.3, 0, 0], alongTip);
|
|
88760
|
-
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);
|
|
88761
88981
|
const marks = [-0.3, -0.1, 0.1].map((x) => mesh3(bx(0.012, 0.15, 0.15), plastic(2781109), [x, 0, 0]));
|
|
88762
88982
|
return G(barrel, flange, stopper, rod, thumbRest, hub, needle, ...marks);
|
|
88763
88983
|
};
|
|
@@ -88792,13 +89012,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
88792
89012
|
return G(foam, core, strapLeft, strapRight);
|
|
88793
89013
|
};
|
|
88794
89014
|
var thermometer = ({ mesh: mesh3, bx, cyl, G, plastic, metal: metal2, glass }) => {
|
|
88795
|
-
const
|
|
89015
|
+
const along3 = [0, 0, -Math.PI / 2];
|
|
88796
89016
|
const body = mesh3(bx(0.8, 0.17, 0.3), plastic(15922421), [-0.2, -0.01, 0]);
|
|
88797
89017
|
const screen2 = mesh3(bx(0.34, 0.03, 0.16), glass(10471332, 0.9), [-0.3, 0.088, 0]);
|
|
88798
89018
|
const button = mesh3(cyl(0.05, 0.05, 0.03, 10), plastic(2788054), [0, 0.088, 0]);
|
|
88799
|
-
const collar = mesh3(cyl(0.07, 0.07, 0.04, 10), plastic(13949404), [0.22, 0, 0],
|
|
88800
|
-
const
|
|
88801
|
-
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);
|
|
88802
89022
|
};
|
|
88803
89023
|
var alcohol70 = ({ mesh: mesh3, cyl, lathe: lathe2, G, glass, plastic, paper: paper2 }) => {
|
|
88804
89024
|
const slim = [1, 1, 0.714];
|
|
@@ -91198,8 +91418,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
91198
91418
|
var hasItemModel = (id) => defaultItemModels().has(id);
|
|
91199
91419
|
var DEFAULT_COLOR = 9080724;
|
|
91200
91420
|
var PI13 = Math.PI;
|
|
91201
|
-
function shade2(color2,
|
|
91202
|
-
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)));
|
|
91203
91423
|
return channel(16) << 16 | channel(8) << 8 | channel(0);
|
|
91204
91424
|
}
|
|
91205
91425
|
var PROUD = 2e-3;
|
|
@@ -91953,8 +92173,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
91953
92173
|
hand.updateMatrixWorld(true);
|
|
91954
92174
|
const at4 = model.localToWorld(v.copy(frontOf));
|
|
91955
92175
|
if (inLens) toWorldLens(camera2, at4, camera2.fov ?? 72, VIEW_HOLD.tool.fov);
|
|
91956
|
-
const
|
|
91957
|
-
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 };
|
|
91958
92178
|
},
|
|
91959
92179
|
handTargets() {
|
|
91960
92180
|
const held = heldHold();
|
|
@@ -92772,7 +92992,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
92772
92992
|
const middle = fitted.integral === true ? -length2 / 2 : length2 / 2;
|
|
92773
92993
|
cylinderX(group, radius, length2, isImprovised ? M.rust : M.dark, middle, 0, 0, 18);
|
|
92774
92994
|
if (isImprovised) {
|
|
92775
|
-
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);
|
|
92776
92996
|
cylinderX(group, radius * 0.7, 8e-3, M.rustD, middle + length2 / 2 - 25e-4, 0, 0, 14);
|
|
92777
92997
|
} else {
|
|
92778
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);
|
|
@@ -94242,11 +94462,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94242
94462
|
this.spare.push(record);
|
|
94243
94463
|
}
|
|
94244
94464
|
/** Keeps the records `keep` accepts, in the same order, without allocating. `context` goes to `keep` so no closure is needed per frame. */
|
|
94245
|
-
compact(
|
|
94465
|
+
compact(keep2, context) {
|
|
94246
94466
|
let write = 0;
|
|
94247
94467
|
for (let read = 0; read < this.items.length; read++) {
|
|
94248
94468
|
const record = this.items[read];
|
|
94249
|
-
if (
|
|
94469
|
+
if (keep2(record, context)) {
|
|
94250
94470
|
this.items[write++] = record;
|
|
94251
94471
|
continue;
|
|
94252
94472
|
}
|
|
@@ -94496,12 +94716,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94496
94716
|
function streamFor3(eventSeed) {
|
|
94497
94717
|
return lehmer(mixEventSeed(eventSeed));
|
|
94498
94718
|
}
|
|
94719
|
+
var MAX_PAD = 0.45;
|
|
94499
94720
|
var SKIN = 5e-3;
|
|
94500
94721
|
var Solids = class {
|
|
94501
94722
|
constructor() {
|
|
94502
94723
|
__publicField3(this, "queries", /* @__PURE__ */ new Map());
|
|
94503
94724
|
__publicField3(this, "list", []);
|
|
94504
|
-
__publicField3(this, "hit", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
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 });
|
|
94505
94726
|
}
|
|
94506
94727
|
get empty() {
|
|
94507
94728
|
return this.list.length === 0;
|
|
@@ -94517,18 +94738,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94517
94738
|
this.list = [];
|
|
94518
94739
|
}
|
|
94519
94740
|
/**
|
|
94520
|
-
* Stops a step that goes into a solid: `out` gets the nearest hit, put back `pad` metres off the surface (never behind where the step began) and
|
|
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
|
|
94521
94742
|
* the surface's normal. Answers whether the step was stopped.
|
|
94522
94743
|
*/
|
|
94523
|
-
stop(move2,
|
|
94744
|
+
stop(move2, out) {
|
|
94524
94745
|
const dx = move2.x1 - move2.x0;
|
|
94525
94746
|
const dy = move2.y1 - move2.y0;
|
|
94526
94747
|
const dz = move2.z1 - move2.z0;
|
|
94527
|
-
const length2 = Math.
|
|
94748
|
+
const length2 = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
94528
94749
|
if (!(length2 > 0)) return false;
|
|
94529
94750
|
let nearest = Infinity;
|
|
94530
|
-
|
|
94531
|
-
|
|
94751
|
+
const list2 = this.list;
|
|
94752
|
+
for (let index = 0; index < list2.length; index++) {
|
|
94753
|
+
if (!list2[index](move2, this.hit)) continue;
|
|
94532
94754
|
const reached = ((this.hit.x - move2.x0) * dx + (this.hit.y - move2.y0) * dy + (this.hit.z - move2.z0) * dz) / length2;
|
|
94533
94755
|
if (reached >= nearest) continue;
|
|
94534
94756
|
nearest = reached;
|
|
@@ -94540,15 +94762,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94540
94762
|
out.nz = this.hit.nz;
|
|
94541
94763
|
}
|
|
94542
94764
|
if (nearest === Infinity) return false;
|
|
94543
|
-
const
|
|
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));
|
|
94544
94770
|
out.x -= dx / length2 * back2;
|
|
94545
94771
|
out.y -= dy / length2 * back2;
|
|
94546
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
|
+
}
|
|
94547
94779
|
return true;
|
|
94548
94780
|
}
|
|
94549
94781
|
};
|
|
94550
94782
|
var SKIN2 = 5e-3;
|
|
94551
|
-
var MAX_PAD = 0.45;
|
|
94552
94783
|
function rotation(q) {
|
|
94553
94784
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
94554
94785
|
const n = Math.hypot(x, y, z, w) || 1;
|
|
@@ -94573,7 +94804,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94573
94804
|
__publicField3(this, "spaces", /* @__PURE__ */ new Map());
|
|
94574
94805
|
__publicField3(this, "list", []);
|
|
94575
94806
|
__publicField3(this, "random");
|
|
94576
|
-
__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 });
|
|
94577
94808
|
__publicField3(this, "l0", new Float64Array(3));
|
|
94578
94809
|
__publicField3(this, "l1", new Float64Array(3));
|
|
94579
94810
|
__publicField3(this, "q", new Float64Array(3));
|
|
@@ -94648,7 +94879,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94648
94879
|
}
|
|
94649
94880
|
/** Passes at `rate` per second. */
|
|
94650
94881
|
chance(rate, dt) {
|
|
94651
|
-
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);
|
|
94652
94883
|
}
|
|
94653
94884
|
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
94654
94885
|
through(s, q, dt) {
|
|
@@ -94671,7 +94902,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94671
94902
|
}
|
|
94672
94903
|
confineMove(move2, dt) {
|
|
94673
94904
|
if (this.confineSpaces(move2, dt)) return true;
|
|
94674
|
-
return !this.solids.empty && this.solids.stop(move2,
|
|
94905
|
+
return !this.solids.empty && this.solids.stop(move2, this.out);
|
|
94675
94906
|
}
|
|
94676
94907
|
confineSpaces(move2, dt) {
|
|
94677
94908
|
const list2 = this.list;
|
|
@@ -94741,6 +94972,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94741
94972
|
out.nx = r[axis2] * sign2;
|
|
94742
94973
|
out.ny = r[3 + axis2] * sign2;
|
|
94743
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]);
|
|
94744
94976
|
return true;
|
|
94745
94977
|
}
|
|
94746
94978
|
return false;
|
|
@@ -94758,6 +94990,127 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94758
94990
|
if (into >= 0) return [vx2, vy2, vz2];
|
|
94759
94991
|
return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
|
|
94760
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
|
+
}
|
|
94761
95114
|
var FLOOR_FRACTION = 0.4;
|
|
94762
95115
|
var FLOOR_BOUNCE = -0.2;
|
|
94763
95116
|
var ARRIVAL_FRAME = 30;
|
|
@@ -94797,7 +95150,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94797
95150
|
age: 0,
|
|
94798
95151
|
heat: 0,
|
|
94799
95152
|
size: 0,
|
|
94800
|
-
source: void 0
|
|
95153
|
+
source: void 0,
|
|
95154
|
+
cuts: [createCut(), createCut()]
|
|
94801
95155
|
}));
|
|
94802
95156
|
}
|
|
94803
95157
|
function spawnPuff(pool, random, init) {
|
|
@@ -94831,6 +95185,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94831
95185
|
puff3.heat = 0;
|
|
94832
95186
|
puff3.size = 0;
|
|
94833
95187
|
puff3.source = init.source;
|
|
95188
|
+
clearCuts(puff3);
|
|
94834
95189
|
return puff3;
|
|
94835
95190
|
}
|
|
94836
95191
|
function ageOrKeep2(puff3, dt) {
|
|
@@ -94880,17 +95235,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94880
95235
|
MOVE.z0 = puff3.z;
|
|
94881
95236
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
94882
95237
|
else moveFree(puff3, dt, age, heat, wind);
|
|
94883
|
-
|
|
95238
|
+
const carried = confining && CARRIED_KINDS[puff3.kind];
|
|
95239
|
+
if (carried && confine(confiner, puff3, dt)) {
|
|
94884
95240
|
const out = confiner.out;
|
|
94885
95241
|
puff3.x = out.x;
|
|
94886
95242
|
puff3.y = out.y;
|
|
94887
95243
|
puff3.z = out.z;
|
|
94888
95244
|
slideInto(out, puff3);
|
|
95245
|
+
cutFrom(puff3, out);
|
|
94889
95246
|
}
|
|
94890
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);
|
|
94891
95248
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
94892
95249
|
puff3.age = age;
|
|
94893
95250
|
puff3.heat = heat;
|
|
95251
|
+
if (carried) lookForWalls(confiner, puff3);
|
|
95252
|
+
else clearCuts(puff3);
|
|
94894
95253
|
}
|
|
94895
95254
|
}
|
|
94896
95255
|
var GROUND_LIFT = 0.02;
|
|
@@ -95786,11 +96145,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
95786
96145
|
function plus(vector2, x, y, z) {
|
|
95787
96146
|
return [vector2[0] + x, vector2[1] + y, vector2[2] + z];
|
|
95788
96147
|
}
|
|
95789
|
-
function scaledBy(vector2,
|
|
95790
|
-
return [vector2[0] *
|
|
96148
|
+
function scaledBy(vector2, factor2) {
|
|
96149
|
+
return [vector2[0] * factor2, vector2[1] * factor2, vector2[2] * factor2];
|
|
95791
96150
|
}
|
|
95792
|
-
function plusScaled(vector2, direction,
|
|
95793
|
-
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];
|
|
95794
96153
|
}
|
|
95795
96154
|
function negated(vector2) {
|
|
95796
96155
|
return [-vector2[0], -vector2[1], -vector2[2]];
|
|
@@ -96821,7 +97180,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96821
97180
|
var ORIGIN = [0, 0, 0];
|
|
96822
97181
|
var FACING4 = [0, 0, 1];
|
|
96823
97182
|
var UP11 = [0, 1, 0];
|
|
96824
|
-
var grow = (piece3,
|
|
97183
|
+
var grow = (piece3, factor2) => [piece3[0] * factor2, piece3[1] * factor2, piece3[2] * factor2];
|
|
96825
97184
|
var debrisTone = (look) => or(variable(DEBRIS_COLOR_VARIABLE), look.debris);
|
|
96826
97185
|
var dustTone = (look) => or(variable(DUST_COLOR_VARIABLE), look.dust);
|
|
96827
97186
|
var sparks = (look, count) => look.sparks ? [call2("spark_at", ORIGIN, FACING4, count, 0.9)] : [];
|
|
@@ -97861,10 +98220,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97861
98220
|
var MAX_SCALE = 3;
|
|
97862
98221
|
var MIN_SCALE = 0.6;
|
|
97863
98222
|
function reflected(direction, normal) {
|
|
97864
|
-
const
|
|
97865
|
-
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]];
|
|
97866
98225
|
const length2 = Math.hypot(out[0], out[1], out[2]);
|
|
97867
|
-
if (length2 < 1e-6 || Math.abs(
|
|
98226
|
+
if (length2 < 1e-6 || Math.abs(along22) > 0.98) return normal;
|
|
97868
98227
|
return [out[0] / length2, out[1] / length2, out[2] / length2];
|
|
97869
98228
|
}
|
|
97870
98229
|
var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
|
|
@@ -97897,13 +98256,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97897
98256
|
var UP12 = [0, 1, 0];
|
|
97898
98257
|
var ZERO2 = [0, 0, 0];
|
|
97899
98258
|
var FULL_TURN_DRAWN = 6.283;
|
|
97900
|
-
function scaledSizes(range22,
|
|
97901
|
-
return [range22[0] * Math.sqrt(
|
|
98259
|
+
function scaledSizes(range22, factor2) {
|
|
98260
|
+
return [range22[0] * Math.sqrt(factor2), range22[1] * Math.sqrt(factor2)];
|
|
97902
98261
|
}
|
|
97903
|
-
function fireEmit(engine, key2, dt, centre, radius,
|
|
98262
|
+
function fireEmit(engine, key2, dt, centre, radius, factor2, options = {}) {
|
|
97904
98263
|
const wind = options.wind ?? ZERO2;
|
|
97905
|
-
const sqrtFactor = Math.sqrt(
|
|
97906
|
-
engine.emit(`${key2}f`, "add", 90 *
|
|
98264
|
+
const sqrtFactor = Math.sqrt(factor2);
|
|
98265
|
+
engine.emit(`${key2}f`, "add", 90 * factor2, dt, () => ({
|
|
97907
98266
|
p: centre,
|
|
97908
98267
|
r: radius,
|
|
97909
98268
|
flat: true,
|
|
@@ -97912,7 +98271,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97912
98271
|
sp: [0.4, 1.4],
|
|
97913
98272
|
v: wind,
|
|
97914
98273
|
life: [0.35, 0.85],
|
|
97915
|
-
size: scaledSizes([0.22, 0.5],
|
|
98274
|
+
size: scaledSizes([0.22, 0.5], factor2),
|
|
97916
98275
|
grow: 0.35,
|
|
97917
98276
|
c0: 16765562,
|
|
97918
98277
|
c1: 9050629,
|
|
@@ -97920,7 +98279,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97920
98279
|
fi: 0.15,
|
|
97921
98280
|
g: -2.2
|
|
97922
98281
|
}));
|
|
97923
|
-
engine.emit(`${key2}c`, "add", 30 *
|
|
98282
|
+
engine.emit(`${key2}c`, "add", 30 * factor2, dt, () => ({
|
|
97924
98283
|
p: centre,
|
|
97925
98284
|
r: radius * 0.6,
|
|
97926
98285
|
flat: true,
|
|
@@ -97928,7 +98287,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97928
98287
|
cone: 0.3,
|
|
97929
98288
|
sp: [0.3, 0.8],
|
|
97930
98289
|
life: [0.2, 0.4],
|
|
97931
|
-
size: scaledSizes([0.25, 0.4],
|
|
98290
|
+
size: scaledSizes([0.25, 0.4], factor2),
|
|
97932
98291
|
grow: 0.6,
|
|
97933
98292
|
c0: 16773824,
|
|
97934
98293
|
c1: 16747040,
|
|
@@ -97937,13 +98296,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97937
98296
|
g: -1
|
|
97938
98297
|
}));
|
|
97939
98298
|
if (engine.quality < 2) {
|
|
97940
|
-
engine.emit(`${key2}e`, "streak", 10 *
|
|
98299
|
+
engine.emit(`${key2}e`, "streak", 10 * factor2, dt, () => {
|
|
97941
98300
|
const jitter = plus(wind, engine.random.between(-0.4, 0.4), 0, engine.random.between(-0.4, 0.4));
|
|
97942
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 };
|
|
97943
98302
|
});
|
|
97944
98303
|
}
|
|
97945
98304
|
if (options.noSmoke) return;
|
|
97946
|
-
engine.emit(`${key2}s`, "normal", (options.smoke || 14) *
|
|
98305
|
+
engine.emit(`${key2}s`, "normal", (options.smoke || 14) * factor2, dt, () => ({
|
|
97947
98306
|
p: plus(centre, 0, 0.8 * sqrtFactor, 0),
|
|
97948
98307
|
r: radius * 0.7,
|
|
97949
98308
|
dir: UP12,
|
|
@@ -97952,7 +98311,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97952
98311
|
v: wind,
|
|
97953
98312
|
drag: 0.15,
|
|
97954
98313
|
life: [2.5, 4.5],
|
|
97955
|
-
size: scaledSizes([0.4, 0.8],
|
|
98314
|
+
size: scaledSizes([0.4, 0.8], factor2),
|
|
97956
98315
|
grow: 4,
|
|
97957
98316
|
c0: options.smokeColor || 2762018,
|
|
97958
98317
|
c1: 1184536,
|
|
@@ -98037,7 +98396,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98037
98396
|
var MACROS = {
|
|
98038
98397
|
blood_hit: ({ engine }, [point, direction, age, scale]) => bloodHit(engine, point, direction, age, scale),
|
|
98039
98398
|
impact: ({ engine }, [material, point, normal, scale, age]) => impact2(engine, material, point, normal, scale, age),
|
|
98040
|
-
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),
|
|
98041
98400
|
explode: ({ engine, cameraPosition }, [point, scale, chipColor]) => explode(engine, point, scale, cameraPosition, chipColor),
|
|
98042
98401
|
muzzle: ({ engine }, [weapon2, tip, direction]) => muzzle(engine, weapon2, tip, direction),
|
|
98043
98402
|
casing: ({ engine }, [port, type]) => casing(engine, port, type),
|
|
@@ -98816,7 +99175,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98816
99175
|
spawnShock(core.shocks, spec);
|
|
98817
99176
|
}
|
|
98818
99177
|
function composeDust(context) {
|
|
98819
|
-
const { core, def, random, x, z, size, scale } = context;
|
|
99178
|
+
const { core, def, random, x, y, z, size, scale } = context;
|
|
98820
99179
|
if (!core.layers.smoke || !def.dust.count || !(scale > 0.15)) return;
|
|
98821
99180
|
const count = Math.round(def.dust.count * scale);
|
|
98822
99181
|
const color2 = hexToLinearRgb(def.dust.color);
|
|
@@ -98846,7 +99205,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98846
99205
|
color: color2,
|
|
98847
99206
|
kind: 1
|
|
98848
99207
|
});
|
|
98849
|
-
bornFrom(core, dust, x,
|
|
99208
|
+
bornFrom(core, dust, x, y, z);
|
|
98850
99209
|
}
|
|
98851
99210
|
}
|
|
98852
99211
|
function coneAngle(context) {
|
|
@@ -99177,6 +99536,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99177
99536
|
state.beat *= Math.exp(-DECAY.beat * dt);
|
|
99178
99537
|
}
|
|
99179
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 };
|
|
99180
99542
|
var clamp42 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
99181
99543
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
99182
99544
|
function rgb(hex2) {
|
|
@@ -99223,6 +99585,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99223
99585
|
__publicField3(this, "bounced");
|
|
99224
99586
|
__publicField3(this, "floor");
|
|
99225
99587
|
__publicField3(this, "riseMul");
|
|
99588
|
+
__publicField3(this, "ground");
|
|
99226
99589
|
const n = Math.max(1, capacity);
|
|
99227
99590
|
this.position = new Float32Array(n * 3);
|
|
99228
99591
|
this.color = new Float32Array(n * 3);
|
|
@@ -99245,6 +99608,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99245
99608
|
this.bounced = new Uint8Array(n);
|
|
99246
99609
|
this.floor = new Float32Array(n);
|
|
99247
99610
|
this.riseMul = new Float32Array(n);
|
|
99611
|
+
this.ground = new Float32Array(n * 3);
|
|
99248
99612
|
}
|
|
99249
99613
|
spawn(kind, p, v, random, options) {
|
|
99250
99614
|
if (this.capacity <= 0) return;
|
|
@@ -99272,6 +99636,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99272
99636
|
this.bounced[i] = 0;
|
|
99273
99637
|
this.floor[i] = options?.floor ?? Number.NaN;
|
|
99274
99638
|
this.riseMul[i] = options?.rise ?? 1;
|
|
99639
|
+
this.ground[i * 3] = Number.NaN;
|
|
99275
99640
|
this.size[i] = this.size0[i];
|
|
99276
99641
|
this.alpha[i] = 0;
|
|
99277
99642
|
}
|
|
@@ -99365,18 +99730,36 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
99365
99730
|
let z = this.position[i3 + 2] + vz2 * dt;
|
|
99366
99731
|
const confiner = host.confiner;
|
|
99367
99732
|
if (def.carried && confiner && !confiner.empty) {
|
|
99368
|
-
|
|
99369
|
-
|
|
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)) {
|
|
99370
99741
|
const out = confiner.out;
|
|
99371
99742
|
x = out.x;
|
|
99372
99743
|
y = out.y;
|
|
99373
99744
|
z = out.z;
|
|
99374
|
-
|
|
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;
|
|
99375
99752
|
}
|
|
99376
99753
|
}
|
|
99377
99754
|
if (def.ground !== "none") {
|
|
99378
99755
|
const own = this.floor[i];
|
|
99379
|
-
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;
|
|
99380
99763
|
if (y < gy) {
|
|
99381
99764
|
if (def.ground === "land") {
|
|
99382
99765
|
const tag = this.tag[i];
|
|
@@ -100222,10 +100605,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
100222
100605
|
if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
|
|
100223
100606
|
particle.vy -= particle.gravity * dt;
|
|
100224
100607
|
if (particle.drag) {
|
|
100225
|
-
const
|
|
100226
|
-
particle.vx *=
|
|
100227
|
-
particle.vy *=
|
|
100228
|
-
particle.vz *=
|
|
100608
|
+
const keep2 = Math.max(0, 1 - particle.drag * dt);
|
|
100609
|
+
particle.vx *= keep2;
|
|
100610
|
+
particle.vy *= keep2;
|
|
100611
|
+
particle.vz *= keep2;
|
|
100229
100612
|
}
|
|
100230
100613
|
if (particle.carried) this.ride(particle, dt);
|
|
100231
100614
|
else {
|
|
@@ -100388,10 +100771,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
100388
100771
|
const offset = index * FLOATS_PER_VECTOR;
|
|
100389
100772
|
const age = 1 - this.life[index] / this.maxLife[index];
|
|
100390
100773
|
velocity2[offset + 1] -= this.gravity[index] * dt;
|
|
100391
|
-
const
|
|
100392
|
-
velocity2[offset] *=
|
|
100393
|
-
velocity2[offset + 1] *=
|
|
100394
|
-
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;
|
|
100395
100778
|
const x0 = position[offset];
|
|
100396
100779
|
const y0 = position[offset + 1];
|
|
100397
100780
|
const z0 = position[offset + 2];
|
|
@@ -100539,10 +100922,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
100539
100922
|
const offset = index * FLOATS_PER_VECTOR2;
|
|
100540
100923
|
const age = 1 - this.life[index] / this.maxLife[index];
|
|
100541
100924
|
velocity2[offset + 1] -= this.gravity[index] * dt;
|
|
100542
|
-
const
|
|
100543
|
-
velocity2[offset] *=
|
|
100544
|
-
velocity2[offset + 1] *=
|
|
100545
|
-
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;
|
|
100546
100929
|
point[offset] += velocity2[offset] * dt;
|
|
100547
100930
|
point[offset + 1] += velocity2[offset + 1] * dt;
|
|
100548
100931
|
point[offset + 2] += velocity2[offset + 2] * dt;
|
|
@@ -100878,16 +101261,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
100878
101261
|
if (profile === void 0) return PROFILES.medium;
|
|
100879
101262
|
return typeof profile === "string" ? PROFILES[profile] : profile;
|
|
100880
101263
|
}
|
|
100881
|
-
function scaleDefinition(def,
|
|
100882
|
-
if (
|
|
100883
|
-
const mushroom = def.mushroom && { ...def.mushroom, height: def.mushroom.height *
|
|
100884
|
-
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 }));
|
|
100885
101268
|
return {
|
|
100886
101269
|
...def,
|
|
100887
|
-
lethal: def.lethal *
|
|
100888
|
-
injury: def.injury *
|
|
100889
|
-
visualRadius: def.visualRadius *
|
|
100890
|
-
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 },
|
|
100891
101274
|
...mushroom ? { mushroom } : {},
|
|
100892
101275
|
...residual ? { residualFires: residual } : {}
|
|
100893
101276
|
};
|
|
@@ -101069,10 +101452,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
101069
101452
|
for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
|
|
101070
101453
|
},
|
|
101071
101454
|
clearSource(source) {
|
|
101072
|
-
const
|
|
101455
|
+
const keep2 = (record, gone) => record.source !== gone;
|
|
101073
101456
|
const drop = (pool) => {
|
|
101074
101457
|
const before = pool.count;
|
|
101075
|
-
pool.compact(
|
|
101458
|
+
pool.compact(keep2, source);
|
|
101076
101459
|
return before - pool.count;
|
|
101077
101460
|
};
|
|
101078
101461
|
return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
|
|
@@ -101169,7 +101552,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
101169
101552
|
}
|
|
101170
101553
|
var DEGREES = 180 / Math.PI;
|
|
101171
101554
|
|
|
101172
|
-
// ../game-vfx-three/dist/chunk-
|
|
101555
|
+
// ../game-vfx-three/dist/chunk-JM23474M.js
|
|
101173
101556
|
var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
|
|
101174
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]);
|
|
101175
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.);}`;
|
|
@@ -101183,23 +101566,24 @@ float vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);
|
|
|
101183
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),
|
|
101184
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);}
|
|
101185
101568
|
`;
|
|
101569
|
+
var PUFF_BASE = (PUFF_REACH - 0.5).toFixed(2);
|
|
101186
101570
|
var PUFF_VERTEX = `${GL_NOISE}
|
|
101187
|
-
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;
|
|
101188
101572
|
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
101189
101573
|
void main(){
|
|
101190
101574
|
vec3 p=position;
|
|
101191
101575
|
float s=aD.z;
|
|
101192
101576
|
float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
|
|
101193
|
-
p
|
|
101577
|
+
p*=${PUFF_BASE}+0.5*n;
|
|
101194
101578
|
float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;
|
|
101195
101579
|
vL=p;
|
|
101196
101580
|
vec3 wp=aP.xyz+p*aP.w;
|
|
101197
|
-
vWP=wp;vD=aD;vC=aC;
|
|
101581
|
+
vWP=wp;vD=aD;vC=aC;vK=aK;vK2=aK2;
|
|
101198
101582
|
gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
|
|
101199
101583
|
}`;
|
|
101200
101584
|
var PUFF_FRAGMENT = `${GL_NOISE}
|
|
101201
101585
|
uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
|
|
101202
|
-
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
101586
|
+
varying vec4 vK;varying vec4 vK2;varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
101203
101587
|
vec3 L(vec3 c){return pow(c,vec3(2.2));}
|
|
101204
101588
|
vec3 ramp(float h){
|
|
101205
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));
|
|
@@ -101209,6 +101593,8 @@ vec3 ramp(float h){
|
|
|
101209
101593
|
return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
|
|
101210
101594
|
}
|
|
101211
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;
|
|
101212
101598
|
vec3 N=normalize(cross(dFdx(vWP),dFdy(vWP)));
|
|
101213
101599
|
float age=vD.x,heat=vD.y,kind=vD.w;
|
|
101214
101600
|
float n=vn(vL*2.4+vD.z*13.0);
|
|
@@ -101237,23 +101623,23 @@ void main(){
|
|
|
101237
101623
|
#include <colorspace_fragment>
|
|
101238
101624
|
}`;
|
|
101239
101625
|
var SOFT_PUFF_VERTEX = `${GL_NOISE}
|
|
101240
|
-
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;
|
|
101241
101627
|
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
101242
101628
|
void main(){
|
|
101243
101629
|
vec3 p=position;
|
|
101244
101630
|
vec3 q=normalize(position);
|
|
101245
101631
|
float s=aD.z;
|
|
101246
101632
|
float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
|
|
101247
|
-
p
|
|
101633
|
+
p*=${PUFF_BASE}+0.5*n;
|
|
101248
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;
|
|
101249
101635
|
vL=p;vN=q;
|
|
101250
101636
|
vec3 wp=aP.xyz+p*aP.w;
|
|
101251
|
-
vWP=wp;vD=aD;vC=aC;
|
|
101637
|
+
vWP=wp;vD=aD;vC=aC;vK=aK;vK2=aK2;
|
|
101252
101638
|
gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
|
|
101253
101639
|
}`;
|
|
101254
101640
|
var SOFT_PUFF_FRAGMENT = `${GL_NOISE}
|
|
101255
101641
|
uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
|
|
101256
|
-
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;
|
|
101257
101643
|
vec3 L(vec3 c){return pow(c,vec3(2.2));}
|
|
101258
101644
|
vec3 ramp(float h){
|
|
101259
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));
|
|
@@ -101263,6 +101649,8 @@ vec3 ramp(float h){
|
|
|
101263
101649
|
return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
|
|
101264
101650
|
}
|
|
101265
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;
|
|
101266
101654
|
float age=vD.x,heat=vD.y,kind=vD.w;
|
|
101267
101655
|
float n=vn(vL*2.4+vD.z*13.0);
|
|
101268
101656
|
// the sphere's own normal, roughened by the noise: a billowing cloud, never facets
|
|
@@ -101326,6 +101714,13 @@ void main(){
|
|
|
101326
101714
|
function dynamic(THREE, array, size) {
|
|
101327
101715
|
return new THREE.InstancedBufferAttribute(array, size).setUsage(THREE.DynamicDrawUsage);
|
|
101328
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
|
+
}
|
|
101329
101724
|
var PUFF_DETAIL = { faceted: 1, soft: 2 };
|
|
101330
101725
|
function createPuffLayer(THREE, pool, uniforms, style = "faceted") {
|
|
101331
101726
|
const capacity = pool.capacity;
|
|
@@ -101334,10 +101729,14 @@ void main(){
|
|
|
101334
101729
|
const a = new Float32Array(capacity * 4);
|
|
101335
101730
|
const d = new Float32Array(capacity * 4);
|
|
101336
101731
|
const c = new Float32Array(capacity * 3);
|
|
101337
|
-
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)];
|
|
101338
101735
|
geometry.setAttribute("aP", attributes[0]);
|
|
101339
101736
|
geometry.setAttribute("aD", attributes[1]);
|
|
101340
101737
|
geometry.setAttribute("aC", attributes[2]);
|
|
101738
|
+
geometry.setAttribute("aK", attributes[3]);
|
|
101739
|
+
geometry.setAttribute("aK2", attributes[4]);
|
|
101341
101740
|
geometry.instanceCount = 0;
|
|
101342
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 });
|
|
101343
101742
|
const mesh3 = new THREE.Mesh(geometry, material);
|
|
@@ -101359,6 +101758,8 @@ void main(){
|
|
|
101359
101758
|
c[n * 3] = p.color[0];
|
|
101360
101759
|
c[n * 3 + 1] = p.color[1];
|
|
101361
101760
|
c[n * 3 + 2] = p.color[2];
|
|
101761
|
+
writeCut(k, n, p.cuts[0]);
|
|
101762
|
+
writeCut(k2, n, p.cuts[1]);
|
|
101362
101763
|
n++;
|
|
101363
101764
|
}
|
|
101364
101765
|
geometry.instanceCount = n;
|
|
@@ -104425,9 +104826,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
104425
104826
|
hand.updateMatrixWorld(true);
|
|
104426
104827
|
const at4 = worldPositionOf(session, mark, muzzleAt);
|
|
104427
104828
|
if (lens2) toWorldLens(camera2, at4, worldFovOf(), lens2.fov);
|
|
104428
|
-
const
|
|
104829
|
+
const along3 = muzzleAlong.set(1, 0, 0).applyQuaternion(session.model.root.getWorldQuaternion(rootQuaternion)).normalize();
|
|
104429
104830
|
const kind = session.def.action.kind;
|
|
104430
|
-
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" };
|
|
104431
104832
|
},
|
|
104432
104833
|
handTargets() {
|
|
104433
104834
|
const held = heldHold();
|
|
@@ -107226,7 +107627,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
107226
107627
|
origin.set(body.objectId, body.from);
|
|
107227
107628
|
}
|
|
107228
107629
|
const partsBefore = new Map(placed.map((body) => [body.objectId, partsOf(body.objectId)]));
|
|
107229
|
-
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) ?? [] }]);
|
|
107230
107631
|
const heavyBefore = new Map(placed.filter((body) => HEAVY_ITEMS.includes(body.kind)).map((body) => [body.objectId, new Map(partPlaces(body.objectId))]));
|
|
107231
107632
|
const heavyShift = (objectId) => {
|
|
107232
107633
|
const before = heavyBefore.get(objectId);
|