@adatechnology/game-items-three 0.11.8 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-64JEKMFT.js → chunk-DBIE2ZMX.js} +14 -4
- package/dist/chunk-DBIE2ZMX.js.map +1 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.global.js +1536 -962
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{testing-D2tqWTG4.d.ts → testing-Y05TqYH8.d.ts} +2 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +16 -16
- package/dist/chunk-64JEKMFT.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -93,6 +93,454 @@ var GameItemsThree = (() => {
|
|
|
93
93
|
wearableMaterials: () => wearableMaterials
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
+
// ../game-contracts/dist/index.js
|
|
97
|
+
var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
|
|
98
|
+
var NEAREST = 0.3;
|
|
99
|
+
function sideOnImpulse(tnt, distance2, nearest = NEAREST) {
|
|
100
|
+
if (!(tnt > 0)) return 0;
|
|
101
|
+
const w3 = Math.cbrt(tnt);
|
|
102
|
+
const z = Math.max(distance2, nearest) / w3;
|
|
103
|
+
const near = z / 0.23 * (z / 0.23);
|
|
104
|
+
const far = z / 1.55;
|
|
105
|
+
const scaled = 0.067 * Math.sqrt(1 + near * near) / (z * z * Math.cbrt(1 + far * far * far));
|
|
106
|
+
return scaled * w3 * 100;
|
|
107
|
+
}
|
|
108
|
+
var ATMOSPHERE = 101325;
|
|
109
|
+
function sideOnOverpressure(tnt, distance2, nearest = NEAREST) {
|
|
110
|
+
if (!(tnt > 0)) return 0;
|
|
111
|
+
const z = Math.max(distance2, nearest) / Math.cbrt(tnt);
|
|
112
|
+
const ratio = 808 * (1 + (z / 4.5) ** 2) / (Math.sqrt(1 + (z / 0.048) ** 2) * Math.sqrt(1 + (z / 0.32) ** 2) * Math.sqrt(1 + (z / 1.35) ** 2));
|
|
113
|
+
return ratio * ATMOSPHERE;
|
|
114
|
+
}
|
|
115
|
+
function bodyImpulse(tnt, distance2) {
|
|
116
|
+
if (!(tnt > 0)) return 0;
|
|
117
|
+
const z = Math.max(distance2, NEAREST) / Math.cbrt(tnt);
|
|
118
|
+
return sideOnImpulse(tnt, distance2) * (2 + 4 / (1 + z * z));
|
|
119
|
+
}
|
|
120
|
+
var CHARGE_RADIUS = 1.3;
|
|
121
|
+
var CHARGE_SECONDS = 0.01;
|
|
122
|
+
var CHARGE_FLUX = 15e5;
|
|
123
|
+
var FUEL_RADIUS = 2.9;
|
|
124
|
+
var FUEL_SECONDS = 0.45;
|
|
125
|
+
var FUEL_FLUX = 25e4;
|
|
126
|
+
var DOSE_PER_DEGREE = 300;
|
|
127
|
+
function chargeFireball(tnt) {
|
|
128
|
+
const cube = Math.cbrt(Math.max(0, tnt));
|
|
129
|
+
return { radius: CHARGE_RADIUS * cube, seconds: CHARGE_SECONDS * cube, flux: CHARGE_FLUX };
|
|
130
|
+
}
|
|
131
|
+
function fuelFireball(fuel) {
|
|
132
|
+
const cube = Math.cbrt(Math.max(0, fuel));
|
|
133
|
+
return { radius: FUEL_RADIUS * cube, seconds: FUEL_SECONDS * cube, flux: FUEL_FLUX };
|
|
134
|
+
}
|
|
135
|
+
function fireballDose(fireball, distance2) {
|
|
136
|
+
const share = distance2 <= fireball.radius ? 1 : (fireball.radius / distance2) ** 2;
|
|
137
|
+
return fireball.flux * fireball.seconds * share;
|
|
138
|
+
}
|
|
139
|
+
function ignitionDose(ignitionC, ambientC = 20) {
|
|
140
|
+
return DOSE_PER_DEGREE * Math.max(1, ignitionC - ambientC);
|
|
141
|
+
}
|
|
142
|
+
var ATMOSPHERE2 = 101325;
|
|
143
|
+
var NEAREST_SCALED = 0.2;
|
|
144
|
+
var LOADED_MARGIN = 0.15;
|
|
145
|
+
var TNT_JOULES = 4184e3;
|
|
146
|
+
var SHOCK_COUPLING = 0.04;
|
|
147
|
+
var SHOCK_SCALED = 0.6;
|
|
148
|
+
function reflectedLoad(tnt, distance2) {
|
|
149
|
+
if (!(tnt > 0)) return { pressure: 0, impulse: 0 };
|
|
150
|
+
const cube = Math.cbrt(tnt);
|
|
151
|
+
const nearest = NEAREST_SCALED * cube;
|
|
152
|
+
const side = sideOnOverpressure(tnt, distance2, nearest);
|
|
153
|
+
const z = Math.max(distance2, nearest) / cube;
|
|
154
|
+
const pressure = 2 * side * (7 * ATMOSPHERE2 + 4 * side) / (7 * ATMOSPHERE2 + side);
|
|
155
|
+
const impulse = sideOnImpulse(tnt, distance2, nearest) * (2 + 4 / (1 + z * z));
|
|
156
|
+
return { pressure, impulse };
|
|
157
|
+
}
|
|
158
|
+
function waveWork(input) {
|
|
159
|
+
const load = reflectedLoad(input.tnt, input.distance);
|
|
160
|
+
const reach2 = Math.min(1, Math.max(0, input.reach));
|
|
161
|
+
const pressure = load.pressure * reach2;
|
|
162
|
+
if (!(input.area > 0) || !(input.mass > 0) || pressure <= 0) return { energy: 0, shock: 0, pressure, loaded: 0 };
|
|
163
|
+
const loaded = Math.min(input.area, Math.PI * (input.distance + LOADED_MARGIN) ** 2);
|
|
164
|
+
const mass = input.mass * (loaded / input.area);
|
|
165
|
+
const impulse = load.impulse * reach2 * loaded;
|
|
166
|
+
const impulsive = impulse * impulse / (2 * mass);
|
|
167
|
+
const quasiStatic = pressure * loaded * Math.max(input.thickness, 1e-4);
|
|
168
|
+
return { energy: Math.min(impulsive, quasiStatic), shock: shockWork(input), pressure, loaded };
|
|
169
|
+
}
|
|
170
|
+
function shockWork(input) {
|
|
171
|
+
const cube = Math.cbrt(input.tnt);
|
|
172
|
+
if (!(cube > 0) || !(input.area > 0)) return 0;
|
|
173
|
+
const z = Math.max(input.distance, 0) / cube;
|
|
174
|
+
const radius = Math.cbrt(3 * input.tnt / (4 * Math.PI * 1600));
|
|
175
|
+
const share = Math.min(0.5, input.area / (4 * Math.PI * (input.distance + radius) ** 2));
|
|
176
|
+
const falloff = 1 + z / SHOCK_SCALED * (z / SHOCK_SCALED);
|
|
177
|
+
const reach2 = Math.min(1, Math.max(0, input.reach));
|
|
178
|
+
return SHOCK_COUPLING * input.tnt * TNT_JOULES * share * reach2 * reach2 / (falloff * falloff);
|
|
179
|
+
}
|
|
180
|
+
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
181
|
+
var STRUCTURE_ROLES = ["foundation", "column", "beam", "slab", "wall", "partition", "roof", "stair", "none"];
|
|
182
|
+
var BEARS = [true, false, "a_on_b", "b_on_a"];
|
|
183
|
+
var finite = (n) => typeof n === "number" && Number.isFinite(n);
|
|
184
|
+
var positive = (n) => finite(n) && n > 0;
|
|
185
|
+
var vec3 = (v) => Array.isArray(v) && v.length === 3 && v.every(finite);
|
|
186
|
+
var nonNegative = (n) => n === void 0 || finite(n) && n >= 0;
|
|
187
|
+
var FACES = ["both", "+", "-", "all"];
|
|
188
|
+
var BONDS = ["running", "stack"];
|
|
189
|
+
var checkStagedFields = (p, label, materials, problems) => {
|
|
190
|
+
const known = (m, what) => {
|
|
191
|
+
if (materials && !materials.has(m)) problems.push(`${label} ${what} has unknown material "${String(m)}"`);
|
|
192
|
+
};
|
|
193
|
+
(p?.layers ?? []).forEach((l, i) => {
|
|
194
|
+
known(l?.material, `layer ${i}`);
|
|
195
|
+
if (!positive(l?.thickness)) problems.push(`${label} layer ${i} thickness must be finite and positive`);
|
|
196
|
+
if (!FACES.includes(l?.faces)) problems.push(`${label} layer ${i} has an invalid faces "${String(l?.faces)}"`);
|
|
197
|
+
});
|
|
198
|
+
const r = p?.reinforcement;
|
|
199
|
+
if (r) {
|
|
200
|
+
known(r.material, "reinforcement");
|
|
201
|
+
if (!positive(r.spacing) || !positive(r.diameter)) problems.push(`${label} reinforcement spacing and diameter must be finite and positive`);
|
|
202
|
+
if (r.residualCapacity !== void 0 && !(finite(r.residualCapacity) && r.residualCapacity >= 0 && r.residualCapacity <= 1)) problems.push(`${label} reinforcement residualCapacity must be between 0 and 1`);
|
|
203
|
+
}
|
|
204
|
+
const u = p?.units;
|
|
205
|
+
if (u) {
|
|
206
|
+
known(u.mortar, "units mortar");
|
|
207
|
+
if (!vec3(u.size) || !u.size.every(positive)) problems.push(`${label} units size must be three finite positive numbers`);
|
|
208
|
+
if (!BONDS.includes(u.bond)) problems.push(`${label} units has an invalid bond "${String(u.bond)}"`);
|
|
209
|
+
}
|
|
210
|
+
if (p?.breach && p.breach.area !== void 0 && !positive(p.breach.area)) problems.push(`${label} breach area must be finite and positive`);
|
|
211
|
+
};
|
|
212
|
+
var checkSpec = (spec, options = {}) => {
|
|
213
|
+
const problems = [];
|
|
214
|
+
const warnings = [];
|
|
215
|
+
const materials = options.materials ? new Set(options.materials) : null;
|
|
216
|
+
const parts2 = Array.isArray(spec?.parts) ? spec.parts : [];
|
|
217
|
+
if (!Array.isArray(spec?.parts) || parts2.length === 0) problems.push("the spec needs at least one part");
|
|
218
|
+
const ids = /* @__PURE__ */ new Set();
|
|
219
|
+
for (const p of parts2) {
|
|
220
|
+
const id = String(p?.id ?? "");
|
|
221
|
+
const label = `part "${id}"`;
|
|
222
|
+
if (id === "") problems.push("a part has no id");
|
|
223
|
+
else if (ids.has(id)) problems.push(`duplicate part id "${id}"`);
|
|
224
|
+
ids.add(id);
|
|
225
|
+
if (materials && !materials.has(p?.material)) problems.push(`${label} has unknown material "${String(p?.material)}"`);
|
|
226
|
+
else if (typeof p?.material !== "string" || p.material === "") problems.push(`${label} needs a material`);
|
|
227
|
+
const s = p?.shape;
|
|
228
|
+
if (s?.kind === "box") {
|
|
229
|
+
if (!Array.isArray(s.size) || s.size.length !== 3 || !s.size.every(positive)) problems.push(`${label} box size must be three finite positive numbers`);
|
|
230
|
+
} else if (s?.kind === "cylinder") {
|
|
231
|
+
if (!positive(s.radius) || !positive(s.height)) problems.push(`${label} cylinder radius and height must be finite and positive`);
|
|
232
|
+
} else if (s?.kind === "sphere") {
|
|
233
|
+
if (!positive(s.radius)) problems.push(`${label} sphere radius must be finite and positive`);
|
|
234
|
+
} else problems.push(`${label} has an unknown shape`);
|
|
235
|
+
if (!vec3(p?.position)) problems.push(`${label} needs a finite position [x, y, z]`);
|
|
236
|
+
if (p?.rotation !== void 0 && !vec3(p.rotation)) problems.push(`${label} has an invalid rotation`);
|
|
237
|
+
for (const f of ["mass", "hp", "thickness"]) if (!nonNegative(p?.[f])) problems.push(`${label} ${f} must be a finite number >= 0`);
|
|
238
|
+
if (p?.fill !== void 0 && !(finite(p.fill) && p.fill >= 0 && p.fill <= 1)) problems.push(`${label} fill must be between 0 and 1`);
|
|
239
|
+
if (p?.structure) {
|
|
240
|
+
if (!STRUCTURE_ROLES.includes(p.structure.role)) problems.push(`${label} has an invalid structure role "${String(p.structure.role)}"`);
|
|
241
|
+
if (!nonNegative(p.structure.capacity)) problems.push(`${label} structure capacity must be a finite number >= 0`);
|
|
242
|
+
}
|
|
243
|
+
if (p?.contains && !nonNegative(p.contains.liters)) problems.push(`${label} contains.liters must be a finite number >= 0`);
|
|
244
|
+
checkStagedFields(p, label, materials, problems);
|
|
245
|
+
}
|
|
246
|
+
const jointIds = /* @__PURE__ */ new Set();
|
|
247
|
+
const edges = [];
|
|
248
|
+
for (const j of spec?.joints ?? []) {
|
|
249
|
+
const id = j.id ?? `${j.a}~${j.b}`;
|
|
250
|
+
const label = `joint "${id}"`;
|
|
251
|
+
if (jointIds.has(id)) problems.push(`duplicate joint id "${id}"`);
|
|
252
|
+
jointIds.add(id);
|
|
253
|
+
if (!ids.has(j.a)) problems.push(`${label} references unknown part "${String(j.a)}"`);
|
|
254
|
+
if (!ids.has(j.b)) problems.push(`${label} references unknown part "${String(j.b)}"`);
|
|
255
|
+
if (j.a === j.b) problems.push(`${label} joins part "${String(j.a)}" to itself`);
|
|
256
|
+
if (j.bears !== void 0 && !BEARS.includes(j.bears)) problems.push(`${label} has an invalid bears "${String(j.bears)}"`);
|
|
257
|
+
if (!nonNegative(j.strength)) problems.push(`${label} strength must be a finite number >= 0`);
|
|
258
|
+
if (!nonNegative(j.seconds)) problems.push(`${label} seconds must be a finite number >= 0`);
|
|
259
|
+
if (j.bears !== false && ids.has(j.a) && ids.has(j.b) && j.a !== j.b) edges.push([j.a, j.b]);
|
|
260
|
+
}
|
|
261
|
+
const structural = parts2.filter((p) => p?.structure && p.structure.role !== "none");
|
|
262
|
+
if (structural.length && spec.joints) {
|
|
263
|
+
const anchored = parts2.filter((p) => p.anchored || p.structure?.role === "foundation").map((p) => p.id);
|
|
264
|
+
const adj = /* @__PURE__ */ new Map();
|
|
265
|
+
for (const [a, b] of edges) {
|
|
266
|
+
adj.set(a, [...adj.get(a) ?? [], b]);
|
|
267
|
+
adj.set(b, [...adj.get(b) ?? [], a]);
|
|
268
|
+
}
|
|
269
|
+
const seen = new Set(anchored);
|
|
270
|
+
const queue = [...anchored];
|
|
271
|
+
while (queue.length) {
|
|
272
|
+
for (const n of adj.get(queue.pop()) ?? []) {
|
|
273
|
+
if (seen.has(n)) continue;
|
|
274
|
+
seen.add(n);
|
|
275
|
+
queue.push(n);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const lost = structural.filter((p) => !seen.has(p.id)).map((p) => p.id);
|
|
279
|
+
if (lost.length) warnings.push(`structural part(s) ${lost.map((i) => `"${i}"`).join(", ")} cannot reach an anchored part, so they will fall`);
|
|
280
|
+
}
|
|
281
|
+
return { ok: problems.length === 0, problems, warnings };
|
|
282
|
+
};
|
|
283
|
+
var DEFAULT_IGNITION_RULES = {
|
|
284
|
+
fillCurve: [
|
|
285
|
+
[0, 0.6],
|
|
286
|
+
[0.1, 1],
|
|
287
|
+
[0.35, 0.6],
|
|
288
|
+
[0.65, 0.3],
|
|
289
|
+
[0.9, 0.15],
|
|
290
|
+
[1, 0.12]
|
|
291
|
+
],
|
|
292
|
+
flameFillInfluence: 0.5,
|
|
293
|
+
flameDefaults: { incendiary: 0.7, tracer: 0.2 },
|
|
294
|
+
sparkTarget: { steel: 1, iron: 1, aluminium: 0.25 },
|
|
295
|
+
sparkMetalDefault: 0.5,
|
|
296
|
+
sparkFluid: { diesel: 0.15 },
|
|
297
|
+
fireNear: { radius: 1.5, chancePerSecond: 0.5 }
|
|
298
|
+
};
|
|
299
|
+
var resolveIgnitionRules = (rules) => ({
|
|
300
|
+
...DEFAULT_IGNITION_RULES,
|
|
301
|
+
...rules,
|
|
302
|
+
flameDefaults: { ...DEFAULT_IGNITION_RULES.flameDefaults, ...rules?.flameDefaults },
|
|
303
|
+
sparkTarget: { ...DEFAULT_IGNITION_RULES.sparkTarget, ...rules?.sparkTarget },
|
|
304
|
+
sparkFluid: { ...DEFAULT_IGNITION_RULES.sparkFluid, ...rules?.sparkFluid },
|
|
305
|
+
fireNear: { ...DEFAULT_IGNITION_RULES.fireNear, ...rules?.fireNear }
|
|
306
|
+
});
|
|
307
|
+
var fillFactor = (fill2, curve = DEFAULT_IGNITION_RULES.fillCurve) => {
|
|
308
|
+
if (curve.length === 0) return 1;
|
|
309
|
+
const f = Math.min(1, Math.max(0, fill2));
|
|
310
|
+
if (f <= curve[0][0]) return curve[0][1];
|
|
311
|
+
for (let i = 1; i < curve.length; i++) {
|
|
312
|
+
const [x1, y1] = curve[i];
|
|
313
|
+
const [x0, y0] = curve[i - 1];
|
|
314
|
+
if (f <= x1) return x1 === x0 ? y1 : y0 + (y1 - y0) * (f - x0) / (x1 - x0);
|
|
315
|
+
}
|
|
316
|
+
return curve[curve.length - 1][1];
|
|
317
|
+
};
|
|
318
|
+
var sparkTargetFactor = (materialId, metal, rules = DEFAULT_IGNITION_RULES) => !metal ? 0 : rules.sparkTarget[materialId] ?? rules.sparkMetalDefault;
|
|
319
|
+
var ignitionChance = (hit, target, rules = DEFAULT_IGNITION_RULES) => {
|
|
320
|
+
const k = fillFactor(target.fill, rules.fillCurve);
|
|
321
|
+
const spark = (hit.ignition?.spark ?? 0) * target.sparkTarget * (target.fluid === void 0 ? 1 : rules.sparkFluid[target.fluid] ?? 1) * k;
|
|
322
|
+
const flameBase = hit.ignition?.flame ?? Math.max(hit.incendiary ? rules.flameDefaults.incendiary : 0, hit.tracer ? rules.flameDefaults.tracer : 0);
|
|
323
|
+
const flame = flameBase * (1 - rules.flameFillInfluence * (1 - k));
|
|
324
|
+
return 1 - (1 - Math.min(1, Math.max(0, spark))) * (1 - Math.min(1, Math.max(0, flame)));
|
|
325
|
+
};
|
|
326
|
+
var sealBlock = (seal, state) => {
|
|
327
|
+
if (seal.spoilsWhenBreached && state.breached) return "breached";
|
|
328
|
+
if (seal.spoilsWhenBreached && state.leaked) return "leaked";
|
|
329
|
+
if (!state.opened) return "sealed";
|
|
330
|
+
return void 0;
|
|
331
|
+
};
|
|
332
|
+
var CARRY_HANDLE_TAG = "carryHandle";
|
|
333
|
+
var DEFERRED_QUEUE_ID = {
|
|
334
|
+
DESTRUCTION_EVENTS: "destruction.events",
|
|
335
|
+
BREACH_PAINT: "floorplan.breach-paint",
|
|
336
|
+
BREACH_CUT: "floorplan.breach-cut",
|
|
337
|
+
AUDIO_VOICES: "audio.voices",
|
|
338
|
+
VEHICLE_CREASE: "vehicles.crease",
|
|
339
|
+
AUDIO_OCCLUSION: "audio.occlusion",
|
|
340
|
+
FLUID_FILM: "fluids.film",
|
|
341
|
+
VEHICLE_LOD_BATCH: "vehicles.lod-batch",
|
|
342
|
+
SETTLED_BATCH: "destruction.settled-batch",
|
|
343
|
+
STATIC_BATCH: "render.static-batch",
|
|
344
|
+
ANIMALS_STATIC_BATCH: "animals.static-batch",
|
|
345
|
+
CHARACTERS_STATIC_BATCH: "characters.static-batch",
|
|
346
|
+
HOUSE_SHADOW_BATCH: "floorplan.shadow-batch",
|
|
347
|
+
DESTRUCTION_PREFIT: "destruction.prefit"
|
|
348
|
+
};
|
|
349
|
+
var DEFERRED_PRIORITY = {
|
|
350
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
351
|
+
// every frame: the walls cut since the last frame are painted once each, and a hole must show in the frame of the blast
|
|
352
|
+
[DEFERRED_QUEUE_ID.BREACH_CUT]: { priority: 260, phase: "present", minEveryFrames: 1 },
|
|
353
|
+
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present", minEveryFrames: 1 },
|
|
354
|
+
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
355
|
+
[DEFERRED_QUEUE_ID.AUDIO_OCCLUSION]: { priority: 190, phase: "idle", minEveryFrames: 8 },
|
|
356
|
+
[DEFERRED_QUEUE_ID.FLUID_FILM]: { priority: 120, phase: "idle", minEveryFrames: 2 },
|
|
357
|
+
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" },
|
|
358
|
+
[DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH]: { priority: 90, phase: "idle", minEveryFrames: 4 },
|
|
359
|
+
[DEFERRED_QUEUE_ID.SETTLED_BATCH]: { priority: 70, phase: "idle", minEveryFrames: 8 },
|
|
360
|
+
[DEFERRED_QUEUE_ID.STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
361
|
+
[DEFERRED_QUEUE_ID.ANIMALS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
362
|
+
[DEFERRED_QUEUE_ID.CHARACTERS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
363
|
+
[DEFERRED_QUEUE_ID.HOUSE_SHADOW_BATCH]: { priority: 50, phase: "idle", minEveryFrames: 8 },
|
|
364
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
|
|
365
|
+
};
|
|
366
|
+
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
367
|
+
function drainDetached(queue, budgetMs, clock = () => performance.now()) {
|
|
368
|
+
return queue.run(clock() + budgetMs, clock);
|
|
369
|
+
}
|
|
370
|
+
var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
|
|
371
|
+
var warnedKeys = () => {
|
|
372
|
+
const holder = globalThis;
|
|
373
|
+
return holder[WARNED_KEY] ?? (holder[WARNED_KEY] = /* @__PURE__ */ new Set());
|
|
374
|
+
};
|
|
375
|
+
var isProduction = () => {
|
|
376
|
+
try {
|
|
377
|
+
return process.env.NODE_ENV === "production";
|
|
378
|
+
} catch {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
var isQuiet = () => globalThis.__GAME_KIT_QUIET__ === true;
|
|
383
|
+
var warnOnce = (key2, message) => {
|
|
384
|
+
if (isQuiet() || isProduction()) return;
|
|
385
|
+
const seen = warnedKeys();
|
|
386
|
+
if (seen.has(key2)) return;
|
|
387
|
+
seen.add(key2);
|
|
388
|
+
console.warn(`[game-kit] ${message}`);
|
|
389
|
+
};
|
|
390
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
391
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
392
|
+
var deepMerge = (base2, patch) => {
|
|
393
|
+
if (!patch) return base2;
|
|
394
|
+
const result = { ...base2 };
|
|
395
|
+
for (const [key2, value] of Object.entries(patch)) {
|
|
396
|
+
if (value === void 0 || UNSAFE_KEYS.has(key2)) continue;
|
|
397
|
+
const current = result[key2];
|
|
398
|
+
result[key2] = isPlainObject(current) && isPlainObject(value) ? deepMerge(current, value) : value;
|
|
399
|
+
}
|
|
400
|
+
return result;
|
|
401
|
+
};
|
|
402
|
+
var mergeById = (shipped, extra) => {
|
|
403
|
+
const entries = /* @__PURE__ */ new Map();
|
|
404
|
+
for (const entry2 of [...shipped, ...extra ?? []]) entries.set(entry2.id, entry2);
|
|
405
|
+
return entries;
|
|
406
|
+
};
|
|
407
|
+
var applyPatches = (entries, patches) => {
|
|
408
|
+
for (const [id, patch] of Object.entries(patches ?? {})) {
|
|
409
|
+
const entry2 = entries.get(id);
|
|
410
|
+
if (entry2) entries.set(id, deepMerge(entry2, patch));
|
|
411
|
+
else warnOnce(`registry.patch.${id}`, `patch for "${id}" ignored: no entry has that id`);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
var removeIds = (entries, ids) => {
|
|
415
|
+
for (const id of ids ?? []) {
|
|
416
|
+
if (!entries.delete(id)) warnOnce(`registry.remove.${id}`, `remove of "${id}" ignored: no entry has that id`);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
var defineCategories = (defs, options = {}) => {
|
|
420
|
+
const problems = [];
|
|
421
|
+
const duplicates = (list2) => {
|
|
422
|
+
const ids = /* @__PURE__ */ new Set();
|
|
423
|
+
for (const def of list2) {
|
|
424
|
+
if (ids.has(def.id)) problems.push(`duplicate category "${def.id}"`);
|
|
425
|
+
ids.add(def.id);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
duplicates(defs);
|
|
429
|
+
duplicates(options.extra ?? []);
|
|
430
|
+
const entries = mergeById(defs, options.extra);
|
|
431
|
+
applyPatches(entries, options.patches);
|
|
432
|
+
removeIds(entries, options.remove);
|
|
433
|
+
const chain = (id) => {
|
|
434
|
+
const path = [];
|
|
435
|
+
let current = id;
|
|
436
|
+
while (current !== void 0) {
|
|
437
|
+
const def = entries.get(current);
|
|
438
|
+
if (!def) throw new Error(path.length === 0 ? `unknown category "${current}"` : `category "${path[0]}" has unknown parent "${current}"`);
|
|
439
|
+
if (path.includes(current)) throw new Error(`category cycle: ${[...path, current].reverse().join(" -> ")}`);
|
|
440
|
+
path.push(current);
|
|
441
|
+
current = def.extends;
|
|
442
|
+
}
|
|
443
|
+
return path.reverse();
|
|
444
|
+
};
|
|
445
|
+
const registry = {
|
|
446
|
+
get: (id) => entries.get(id),
|
|
447
|
+
has: (id) => entries.has(id),
|
|
448
|
+
ids: () => [...entries.keys()],
|
|
449
|
+
chain,
|
|
450
|
+
defaults: (id) => chain(id).reduce((acc, ancestor) => deepMerge(acc, entries.get(ancestor)?.defaults), {}),
|
|
451
|
+
requires: (id) => {
|
|
452
|
+
const out = [];
|
|
453
|
+
for (const ancestor of chain(id)) for (const contract of entries.get(ancestor)?.requires ?? []) if (!out.includes(contract)) out.push(contract);
|
|
454
|
+
return out;
|
|
455
|
+
},
|
|
456
|
+
isA: (id, ancestorId) => {
|
|
457
|
+
try {
|
|
458
|
+
return chain(id).includes(ancestorId);
|
|
459
|
+
} catch {
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
check: () => {
|
|
464
|
+
const found = [...problems];
|
|
465
|
+
for (const [id, def] of entries) {
|
|
466
|
+
if (def.extends !== void 0 && !entries.has(def.extends)) found.push(`category "${id}" extends unknown "${def.extends}"`);
|
|
467
|
+
else {
|
|
468
|
+
try {
|
|
469
|
+
chain(id);
|
|
470
|
+
} catch (error) {
|
|
471
|
+
const message = error.message;
|
|
472
|
+
if (message.startsWith("category cycle") && !found.includes(message)) found.push(message);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return found;
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
return registry;
|
|
480
|
+
};
|
|
481
|
+
var resolveEntry = (registry, entry2, kindField = "kind") => deepMerge(registry.defaults(String(entry2[kindField])), entry2);
|
|
482
|
+
var KIT_ORIGIN_KEY = "kitOrigin";
|
|
483
|
+
function markKitOrigin(object2, origin) {
|
|
484
|
+
const node = object2;
|
|
485
|
+
node.userData = node.userData ?? {};
|
|
486
|
+
node.userData[KIT_ORIGIN_KEY] = { ...origin };
|
|
487
|
+
return object2;
|
|
488
|
+
}
|
|
489
|
+
var SURFACE_IDS = ["concrete", "asphalt", "wood", "tile", "dirt", "grass", "gravel", "sand", "metal", "water", "glass", "carpet"];
|
|
490
|
+
var GAIT_IDS = ["walk", "run"];
|
|
491
|
+
var LANDING_IDS = ["light", "heavy"];
|
|
492
|
+
var BODY_SOUND_IDS = [
|
|
493
|
+
"jump",
|
|
494
|
+
"cloth_rustle",
|
|
495
|
+
"body_fall",
|
|
496
|
+
"fall_damage",
|
|
497
|
+
"player_hurt",
|
|
498
|
+
"player_breath_run",
|
|
499
|
+
"player_death",
|
|
500
|
+
"bite",
|
|
501
|
+
"grab",
|
|
502
|
+
"punch_swing",
|
|
503
|
+
"punch_hit_body",
|
|
504
|
+
"punch_hit_face",
|
|
505
|
+
"punch_hit_object",
|
|
506
|
+
"kick_swing",
|
|
507
|
+
"kick_hit",
|
|
508
|
+
"kick_hit_object",
|
|
509
|
+
"shove_two_hands",
|
|
510
|
+
"knife_swing",
|
|
511
|
+
"knife_stab",
|
|
512
|
+
"knife_slash",
|
|
513
|
+
"knife_hit_object",
|
|
514
|
+
"blunt_swing",
|
|
515
|
+
"blunt_hit",
|
|
516
|
+
"blunt_hit_object",
|
|
517
|
+
"axe_swing",
|
|
518
|
+
"axe_chop",
|
|
519
|
+
"axe_hit_object"
|
|
520
|
+
];
|
|
521
|
+
var footstepSoundId = (surface, gait) => `footstep_${surface}_${gait}`;
|
|
522
|
+
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
523
|
+
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
524
|
+
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
525
|
+
var WORKER_KIND_ID = {
|
|
526
|
+
GROUND_TILES: "destruction.ground-tiles",
|
|
527
|
+
CROWD_PHYSICS: "crowd.physics",
|
|
528
|
+
PIECE_BOXES: "destruction.piece-boxes",
|
|
529
|
+
STATIC_COLLIDERS: "destruction.static-colliders",
|
|
530
|
+
SHAPES_GENERATE: "shapes.generate",
|
|
531
|
+
WORLD_REGION: "world.region",
|
|
532
|
+
VEHICLE_HULL_PLAN: "vehicles.hull-plan"
|
|
533
|
+
};
|
|
534
|
+
var WORKER_KIND_DEFAULTS = {
|
|
535
|
+
[WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
|
|
536
|
+
[WORKER_KIND_ID.CROWD_PHYSICS]: { lane: "sim", priority: 250, latencyFrames: 1, late: "sync" },
|
|
537
|
+
[WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
|
|
538
|
+
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
539
|
+
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
540
|
+
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" },
|
|
541
|
+
[WORKER_KIND_ID.VEHICLE_HULL_PLAN]: { lane: "build", priority: 120, late: "keep-waiting" }
|
|
542
|
+
};
|
|
543
|
+
|
|
96
544
|
// ../game-shapes/dist/chunk-QETSTM6M.js
|
|
97
545
|
function canonicalJson(value) {
|
|
98
546
|
if (value === null) return "null";
|
|
@@ -1563,453 +2011,6 @@ var GameItemsThree = (() => {
|
|
|
1563
2011
|
return { positions: positions2, normals, uvs };
|
|
1564
2012
|
}
|
|
1565
2013
|
|
|
1566
|
-
// ../game-contracts/dist/index.js
|
|
1567
|
-
var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
|
|
1568
|
-
var NEAREST = 0.3;
|
|
1569
|
-
function sideOnImpulse(tnt, distance2, nearest = NEAREST) {
|
|
1570
|
-
if (!(tnt > 0)) return 0;
|
|
1571
|
-
const w3 = Math.cbrt(tnt);
|
|
1572
|
-
const z = Math.max(distance2, nearest) / w3;
|
|
1573
|
-
const near = z / 0.23 * (z / 0.23);
|
|
1574
|
-
const far = z / 1.55;
|
|
1575
|
-
const scaled = 0.067 * Math.sqrt(1 + near * near) / (z * z * Math.cbrt(1 + far * far * far));
|
|
1576
|
-
return scaled * w3 * 100;
|
|
1577
|
-
}
|
|
1578
|
-
var ATMOSPHERE = 101325;
|
|
1579
|
-
function sideOnOverpressure(tnt, distance2, nearest = NEAREST) {
|
|
1580
|
-
if (!(tnt > 0)) return 0;
|
|
1581
|
-
const z = Math.max(distance2, nearest) / Math.cbrt(tnt);
|
|
1582
|
-
const ratio = 808 * (1 + (z / 4.5) ** 2) / (Math.sqrt(1 + (z / 0.048) ** 2) * Math.sqrt(1 + (z / 0.32) ** 2) * Math.sqrt(1 + (z / 1.35) ** 2));
|
|
1583
|
-
return ratio * ATMOSPHERE;
|
|
1584
|
-
}
|
|
1585
|
-
function bodyImpulse(tnt, distance2) {
|
|
1586
|
-
if (!(tnt > 0)) return 0;
|
|
1587
|
-
const z = Math.max(distance2, NEAREST) / Math.cbrt(tnt);
|
|
1588
|
-
return sideOnImpulse(tnt, distance2) * (2 + 4 / (1 + z * z));
|
|
1589
|
-
}
|
|
1590
|
-
var CHARGE_RADIUS = 1.3;
|
|
1591
|
-
var CHARGE_SECONDS = 0.01;
|
|
1592
|
-
var CHARGE_FLUX = 15e5;
|
|
1593
|
-
var FUEL_RADIUS = 2.9;
|
|
1594
|
-
var FUEL_SECONDS = 0.45;
|
|
1595
|
-
var FUEL_FLUX = 25e4;
|
|
1596
|
-
var DOSE_PER_DEGREE = 300;
|
|
1597
|
-
function chargeFireball(tnt) {
|
|
1598
|
-
const cube = Math.cbrt(Math.max(0, tnt));
|
|
1599
|
-
return { radius: CHARGE_RADIUS * cube, seconds: CHARGE_SECONDS * cube, flux: CHARGE_FLUX };
|
|
1600
|
-
}
|
|
1601
|
-
function fuelFireball(fuel) {
|
|
1602
|
-
const cube = Math.cbrt(Math.max(0, fuel));
|
|
1603
|
-
return { radius: FUEL_RADIUS * cube, seconds: FUEL_SECONDS * cube, flux: FUEL_FLUX };
|
|
1604
|
-
}
|
|
1605
|
-
function fireballDose(fireball, distance2) {
|
|
1606
|
-
const share = distance2 <= fireball.radius ? 1 : (fireball.radius / distance2) ** 2;
|
|
1607
|
-
return fireball.flux * fireball.seconds * share;
|
|
1608
|
-
}
|
|
1609
|
-
function ignitionDose(ignitionC, ambientC = 20) {
|
|
1610
|
-
return DOSE_PER_DEGREE * Math.max(1, ignitionC - ambientC);
|
|
1611
|
-
}
|
|
1612
|
-
var ATMOSPHERE2 = 101325;
|
|
1613
|
-
var NEAREST_SCALED = 0.2;
|
|
1614
|
-
var LOADED_MARGIN = 0.15;
|
|
1615
|
-
var TNT_JOULES = 4184e3;
|
|
1616
|
-
var SHOCK_COUPLING = 0.04;
|
|
1617
|
-
var SHOCK_SCALED = 0.6;
|
|
1618
|
-
function reflectedLoad(tnt, distance2) {
|
|
1619
|
-
if (!(tnt > 0)) return { pressure: 0, impulse: 0 };
|
|
1620
|
-
const cube = Math.cbrt(tnt);
|
|
1621
|
-
const nearest = NEAREST_SCALED * cube;
|
|
1622
|
-
const side = sideOnOverpressure(tnt, distance2, nearest);
|
|
1623
|
-
const z = Math.max(distance2, nearest) / cube;
|
|
1624
|
-
const pressure = 2 * side * (7 * ATMOSPHERE2 + 4 * side) / (7 * ATMOSPHERE2 + side);
|
|
1625
|
-
const impulse = sideOnImpulse(tnt, distance2, nearest) * (2 + 4 / (1 + z * z));
|
|
1626
|
-
return { pressure, impulse };
|
|
1627
|
-
}
|
|
1628
|
-
function waveWork(input) {
|
|
1629
|
-
const load = reflectedLoad(input.tnt, input.distance);
|
|
1630
|
-
const reach2 = Math.min(1, Math.max(0, input.reach));
|
|
1631
|
-
const pressure = load.pressure * reach2;
|
|
1632
|
-
if (!(input.area > 0) || !(input.mass > 0) || pressure <= 0) return { energy: 0, shock: 0, pressure, loaded: 0 };
|
|
1633
|
-
const loaded = Math.min(input.area, Math.PI * (input.distance + LOADED_MARGIN) ** 2);
|
|
1634
|
-
const mass = input.mass * (loaded / input.area);
|
|
1635
|
-
const impulse = load.impulse * reach2 * loaded;
|
|
1636
|
-
const impulsive = impulse * impulse / (2 * mass);
|
|
1637
|
-
const quasiStatic = pressure * loaded * Math.max(input.thickness, 1e-4);
|
|
1638
|
-
return { energy: Math.min(impulsive, quasiStatic), shock: shockWork(input), pressure, loaded };
|
|
1639
|
-
}
|
|
1640
|
-
function shockWork(input) {
|
|
1641
|
-
const cube = Math.cbrt(input.tnt);
|
|
1642
|
-
if (!(cube > 0) || !(input.area > 0)) return 0;
|
|
1643
|
-
const z = Math.max(input.distance, 0) / cube;
|
|
1644
|
-
const radius = Math.cbrt(3 * input.tnt / (4 * Math.PI * 1600));
|
|
1645
|
-
const share = Math.min(0.5, input.area / (4 * Math.PI * (input.distance + radius) ** 2));
|
|
1646
|
-
const falloff = 1 + z / SHOCK_SCALED * (z / SHOCK_SCALED);
|
|
1647
|
-
const reach2 = Math.min(1, Math.max(0, input.reach));
|
|
1648
|
-
return SHOCK_COUPLING * input.tnt * TNT_JOULES * share * reach2 * reach2 / (falloff * falloff);
|
|
1649
|
-
}
|
|
1650
|
-
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
1651
|
-
var STRUCTURE_ROLES = ["foundation", "column", "beam", "slab", "wall", "partition", "roof", "stair", "none"];
|
|
1652
|
-
var BEARS = [true, false, "a_on_b", "b_on_a"];
|
|
1653
|
-
var finite = (n) => typeof n === "number" && Number.isFinite(n);
|
|
1654
|
-
var positive = (n) => finite(n) && n > 0;
|
|
1655
|
-
var vec3 = (v) => Array.isArray(v) && v.length === 3 && v.every(finite);
|
|
1656
|
-
var nonNegative = (n) => n === void 0 || finite(n) && n >= 0;
|
|
1657
|
-
var FACES = ["both", "+", "-", "all"];
|
|
1658
|
-
var BONDS = ["running", "stack"];
|
|
1659
|
-
var checkStagedFields = (p, label, materials, problems) => {
|
|
1660
|
-
const known = (m, what) => {
|
|
1661
|
-
if (materials && !materials.has(m)) problems.push(`${label} ${what} has unknown material "${String(m)}"`);
|
|
1662
|
-
};
|
|
1663
|
-
(p?.layers ?? []).forEach((l, i) => {
|
|
1664
|
-
known(l?.material, `layer ${i}`);
|
|
1665
|
-
if (!positive(l?.thickness)) problems.push(`${label} layer ${i} thickness must be finite and positive`);
|
|
1666
|
-
if (!FACES.includes(l?.faces)) problems.push(`${label} layer ${i} has an invalid faces "${String(l?.faces)}"`);
|
|
1667
|
-
});
|
|
1668
|
-
const r = p?.reinforcement;
|
|
1669
|
-
if (r) {
|
|
1670
|
-
known(r.material, "reinforcement");
|
|
1671
|
-
if (!positive(r.spacing) || !positive(r.diameter)) problems.push(`${label} reinforcement spacing and diameter must be finite and positive`);
|
|
1672
|
-
if (r.residualCapacity !== void 0 && !(finite(r.residualCapacity) && r.residualCapacity >= 0 && r.residualCapacity <= 1)) problems.push(`${label} reinforcement residualCapacity must be between 0 and 1`);
|
|
1673
|
-
}
|
|
1674
|
-
const u = p?.units;
|
|
1675
|
-
if (u) {
|
|
1676
|
-
known(u.mortar, "units mortar");
|
|
1677
|
-
if (!vec3(u.size) || !u.size.every(positive)) problems.push(`${label} units size must be three finite positive numbers`);
|
|
1678
|
-
if (!BONDS.includes(u.bond)) problems.push(`${label} units has an invalid bond "${String(u.bond)}"`);
|
|
1679
|
-
}
|
|
1680
|
-
if (p?.breach && p.breach.area !== void 0 && !positive(p.breach.area)) problems.push(`${label} breach area must be finite and positive`);
|
|
1681
|
-
};
|
|
1682
|
-
var checkSpec = (spec, options = {}) => {
|
|
1683
|
-
const problems = [];
|
|
1684
|
-
const warnings = [];
|
|
1685
|
-
const materials = options.materials ? new Set(options.materials) : null;
|
|
1686
|
-
const parts2 = Array.isArray(spec?.parts) ? spec.parts : [];
|
|
1687
|
-
if (!Array.isArray(spec?.parts) || parts2.length === 0) problems.push("the spec needs at least one part");
|
|
1688
|
-
const ids = /* @__PURE__ */ new Set();
|
|
1689
|
-
for (const p of parts2) {
|
|
1690
|
-
const id = String(p?.id ?? "");
|
|
1691
|
-
const label = `part "${id}"`;
|
|
1692
|
-
if (id === "") problems.push("a part has no id");
|
|
1693
|
-
else if (ids.has(id)) problems.push(`duplicate part id "${id}"`);
|
|
1694
|
-
ids.add(id);
|
|
1695
|
-
if (materials && !materials.has(p?.material)) problems.push(`${label} has unknown material "${String(p?.material)}"`);
|
|
1696
|
-
else if (typeof p?.material !== "string" || p.material === "") problems.push(`${label} needs a material`);
|
|
1697
|
-
const s = p?.shape;
|
|
1698
|
-
if (s?.kind === "box") {
|
|
1699
|
-
if (!Array.isArray(s.size) || s.size.length !== 3 || !s.size.every(positive)) problems.push(`${label} box size must be three finite positive numbers`);
|
|
1700
|
-
} else if (s?.kind === "cylinder") {
|
|
1701
|
-
if (!positive(s.radius) || !positive(s.height)) problems.push(`${label} cylinder radius and height must be finite and positive`);
|
|
1702
|
-
} else if (s?.kind === "sphere") {
|
|
1703
|
-
if (!positive(s.radius)) problems.push(`${label} sphere radius must be finite and positive`);
|
|
1704
|
-
} else problems.push(`${label} has an unknown shape`);
|
|
1705
|
-
if (!vec3(p?.position)) problems.push(`${label} needs a finite position [x, y, z]`);
|
|
1706
|
-
if (p?.rotation !== void 0 && !vec3(p.rotation)) problems.push(`${label} has an invalid rotation`);
|
|
1707
|
-
for (const f of ["mass", "hp", "thickness"]) if (!nonNegative(p?.[f])) problems.push(`${label} ${f} must be a finite number >= 0`);
|
|
1708
|
-
if (p?.fill !== void 0 && !(finite(p.fill) && p.fill >= 0 && p.fill <= 1)) problems.push(`${label} fill must be between 0 and 1`);
|
|
1709
|
-
if (p?.structure) {
|
|
1710
|
-
if (!STRUCTURE_ROLES.includes(p.structure.role)) problems.push(`${label} has an invalid structure role "${String(p.structure.role)}"`);
|
|
1711
|
-
if (!nonNegative(p.structure.capacity)) problems.push(`${label} structure capacity must be a finite number >= 0`);
|
|
1712
|
-
}
|
|
1713
|
-
if (p?.contains && !nonNegative(p.contains.liters)) problems.push(`${label} contains.liters must be a finite number >= 0`);
|
|
1714
|
-
checkStagedFields(p, label, materials, problems);
|
|
1715
|
-
}
|
|
1716
|
-
const jointIds = /* @__PURE__ */ new Set();
|
|
1717
|
-
const edges = [];
|
|
1718
|
-
for (const j of spec?.joints ?? []) {
|
|
1719
|
-
const id = j.id ?? `${j.a}~${j.b}`;
|
|
1720
|
-
const label = `joint "${id}"`;
|
|
1721
|
-
if (jointIds.has(id)) problems.push(`duplicate joint id "${id}"`);
|
|
1722
|
-
jointIds.add(id);
|
|
1723
|
-
if (!ids.has(j.a)) problems.push(`${label} references unknown part "${String(j.a)}"`);
|
|
1724
|
-
if (!ids.has(j.b)) problems.push(`${label} references unknown part "${String(j.b)}"`);
|
|
1725
|
-
if (j.a === j.b) problems.push(`${label} joins part "${String(j.a)}" to itself`);
|
|
1726
|
-
if (j.bears !== void 0 && !BEARS.includes(j.bears)) problems.push(`${label} has an invalid bears "${String(j.bears)}"`);
|
|
1727
|
-
if (!nonNegative(j.strength)) problems.push(`${label} strength must be a finite number >= 0`);
|
|
1728
|
-
if (!nonNegative(j.seconds)) problems.push(`${label} seconds must be a finite number >= 0`);
|
|
1729
|
-
if (j.bears !== false && ids.has(j.a) && ids.has(j.b) && j.a !== j.b) edges.push([j.a, j.b]);
|
|
1730
|
-
}
|
|
1731
|
-
const structural = parts2.filter((p) => p?.structure && p.structure.role !== "none");
|
|
1732
|
-
if (structural.length && spec.joints) {
|
|
1733
|
-
const anchored = parts2.filter((p) => p.anchored || p.structure?.role === "foundation").map((p) => p.id);
|
|
1734
|
-
const adj = /* @__PURE__ */ new Map();
|
|
1735
|
-
for (const [a, b] of edges) {
|
|
1736
|
-
adj.set(a, [...adj.get(a) ?? [], b]);
|
|
1737
|
-
adj.set(b, [...adj.get(b) ?? [], a]);
|
|
1738
|
-
}
|
|
1739
|
-
const seen = new Set(anchored);
|
|
1740
|
-
const queue = [...anchored];
|
|
1741
|
-
while (queue.length) {
|
|
1742
|
-
for (const n of adj.get(queue.pop()) ?? []) {
|
|
1743
|
-
if (seen.has(n)) continue;
|
|
1744
|
-
seen.add(n);
|
|
1745
|
-
queue.push(n);
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
const lost = structural.filter((p) => !seen.has(p.id)).map((p) => p.id);
|
|
1749
|
-
if (lost.length) warnings.push(`structural part(s) ${lost.map((i) => `"${i}"`).join(", ")} cannot reach an anchored part, so they will fall`);
|
|
1750
|
-
}
|
|
1751
|
-
return { ok: problems.length === 0, problems, warnings };
|
|
1752
|
-
};
|
|
1753
|
-
var DEFAULT_IGNITION_RULES = {
|
|
1754
|
-
fillCurve: [
|
|
1755
|
-
[0, 0.6],
|
|
1756
|
-
[0.1, 1],
|
|
1757
|
-
[0.35, 0.6],
|
|
1758
|
-
[0.65, 0.3],
|
|
1759
|
-
[0.9, 0.15],
|
|
1760
|
-
[1, 0.12]
|
|
1761
|
-
],
|
|
1762
|
-
flameFillInfluence: 0.5,
|
|
1763
|
-
flameDefaults: { incendiary: 0.7, tracer: 0.2 },
|
|
1764
|
-
sparkTarget: { steel: 1, iron: 1, aluminium: 0.25 },
|
|
1765
|
-
sparkMetalDefault: 0.5,
|
|
1766
|
-
sparkFluid: { diesel: 0.15 },
|
|
1767
|
-
fireNear: { radius: 1.5, chancePerSecond: 0.5 }
|
|
1768
|
-
};
|
|
1769
|
-
var resolveIgnitionRules = (rules) => ({
|
|
1770
|
-
...DEFAULT_IGNITION_RULES,
|
|
1771
|
-
...rules,
|
|
1772
|
-
flameDefaults: { ...DEFAULT_IGNITION_RULES.flameDefaults, ...rules?.flameDefaults },
|
|
1773
|
-
sparkTarget: { ...DEFAULT_IGNITION_RULES.sparkTarget, ...rules?.sparkTarget },
|
|
1774
|
-
sparkFluid: { ...DEFAULT_IGNITION_RULES.sparkFluid, ...rules?.sparkFluid },
|
|
1775
|
-
fireNear: { ...DEFAULT_IGNITION_RULES.fireNear, ...rules?.fireNear }
|
|
1776
|
-
});
|
|
1777
|
-
var fillFactor = (fill2, curve = DEFAULT_IGNITION_RULES.fillCurve) => {
|
|
1778
|
-
if (curve.length === 0) return 1;
|
|
1779
|
-
const f = Math.min(1, Math.max(0, fill2));
|
|
1780
|
-
if (f <= curve[0][0]) return curve[0][1];
|
|
1781
|
-
for (let i = 1; i < curve.length; i++) {
|
|
1782
|
-
const [x1, y1] = curve[i];
|
|
1783
|
-
const [x0, y0] = curve[i - 1];
|
|
1784
|
-
if (f <= x1) return x1 === x0 ? y1 : y0 + (y1 - y0) * (f - x0) / (x1 - x0);
|
|
1785
|
-
}
|
|
1786
|
-
return curve[curve.length - 1][1];
|
|
1787
|
-
};
|
|
1788
|
-
var sparkTargetFactor = (materialId, metal, rules = DEFAULT_IGNITION_RULES) => !metal ? 0 : rules.sparkTarget[materialId] ?? rules.sparkMetalDefault;
|
|
1789
|
-
var ignitionChance = (hit, target, rules = DEFAULT_IGNITION_RULES) => {
|
|
1790
|
-
const k = fillFactor(target.fill, rules.fillCurve);
|
|
1791
|
-
const spark = (hit.ignition?.spark ?? 0) * target.sparkTarget * (target.fluid === void 0 ? 1 : rules.sparkFluid[target.fluid] ?? 1) * k;
|
|
1792
|
-
const flameBase = hit.ignition?.flame ?? Math.max(hit.incendiary ? rules.flameDefaults.incendiary : 0, hit.tracer ? rules.flameDefaults.tracer : 0);
|
|
1793
|
-
const flame = flameBase * (1 - rules.flameFillInfluence * (1 - k));
|
|
1794
|
-
return 1 - (1 - Math.min(1, Math.max(0, spark))) * (1 - Math.min(1, Math.max(0, flame)));
|
|
1795
|
-
};
|
|
1796
|
-
var sealBlock = (seal, state) => {
|
|
1797
|
-
if (seal.spoilsWhenBreached && state.breached) return "breached";
|
|
1798
|
-
if (seal.spoilsWhenBreached && state.leaked) return "leaked";
|
|
1799
|
-
if (!state.opened) return "sealed";
|
|
1800
|
-
return void 0;
|
|
1801
|
-
};
|
|
1802
|
-
var DEFERRED_QUEUE_ID = {
|
|
1803
|
-
DESTRUCTION_EVENTS: "destruction.events",
|
|
1804
|
-
BREACH_PAINT: "floorplan.breach-paint",
|
|
1805
|
-
BREACH_CUT: "floorplan.breach-cut",
|
|
1806
|
-
AUDIO_VOICES: "audio.voices",
|
|
1807
|
-
VEHICLE_CREASE: "vehicles.crease",
|
|
1808
|
-
AUDIO_OCCLUSION: "audio.occlusion",
|
|
1809
|
-
FLUID_FILM: "fluids.film",
|
|
1810
|
-
VEHICLE_LOD_BATCH: "vehicles.lod-batch",
|
|
1811
|
-
SETTLED_BATCH: "destruction.settled-batch",
|
|
1812
|
-
STATIC_BATCH: "render.static-batch",
|
|
1813
|
-
ANIMALS_STATIC_BATCH: "animals.static-batch",
|
|
1814
|
-
CHARACTERS_STATIC_BATCH: "characters.static-batch",
|
|
1815
|
-
HOUSE_SHADOW_BATCH: "floorplan.shadow-batch",
|
|
1816
|
-
DESTRUCTION_PREFIT: "destruction.prefit"
|
|
1817
|
-
};
|
|
1818
|
-
var DEFERRED_PRIORITY = {
|
|
1819
|
-
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
1820
|
-
// every frame: the walls cut since the last frame are painted once each, and a hole must show in the frame of the blast
|
|
1821
|
-
[DEFERRED_QUEUE_ID.BREACH_CUT]: { priority: 260, phase: "present", minEveryFrames: 1 },
|
|
1822
|
-
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present", minEveryFrames: 1 },
|
|
1823
|
-
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
1824
|
-
[DEFERRED_QUEUE_ID.AUDIO_OCCLUSION]: { priority: 190, phase: "idle", minEveryFrames: 8 },
|
|
1825
|
-
[DEFERRED_QUEUE_ID.FLUID_FILM]: { priority: 120, phase: "idle", minEveryFrames: 2 },
|
|
1826
|
-
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" },
|
|
1827
|
-
[DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH]: { priority: 90, phase: "idle", minEveryFrames: 4 },
|
|
1828
|
-
[DEFERRED_QUEUE_ID.SETTLED_BATCH]: { priority: 70, phase: "idle", minEveryFrames: 8 },
|
|
1829
|
-
[DEFERRED_QUEUE_ID.STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
1830
|
-
[DEFERRED_QUEUE_ID.ANIMALS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
1831
|
-
[DEFERRED_QUEUE_ID.CHARACTERS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
1832
|
-
[DEFERRED_QUEUE_ID.HOUSE_SHADOW_BATCH]: { priority: 50, phase: "idle", minEveryFrames: 8 },
|
|
1833
|
-
[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
|
|
1834
|
-
};
|
|
1835
|
-
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
1836
|
-
function drainDetached(queue, budgetMs, clock = () => performance.now()) {
|
|
1837
|
-
return queue.run(clock() + budgetMs, clock);
|
|
1838
|
-
}
|
|
1839
|
-
var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
|
|
1840
|
-
var warnedKeys = () => {
|
|
1841
|
-
const holder = globalThis;
|
|
1842
|
-
return holder[WARNED_KEY] ?? (holder[WARNED_KEY] = /* @__PURE__ */ new Set());
|
|
1843
|
-
};
|
|
1844
|
-
var isProduction = () => {
|
|
1845
|
-
try {
|
|
1846
|
-
return process.env.NODE_ENV === "production";
|
|
1847
|
-
} catch {
|
|
1848
|
-
return false;
|
|
1849
|
-
}
|
|
1850
|
-
};
|
|
1851
|
-
var isQuiet = () => globalThis.__GAME_KIT_QUIET__ === true;
|
|
1852
|
-
var warnOnce = (key2, message) => {
|
|
1853
|
-
if (isQuiet() || isProduction()) return;
|
|
1854
|
-
const seen = warnedKeys();
|
|
1855
|
-
if (seen.has(key2)) return;
|
|
1856
|
-
seen.add(key2);
|
|
1857
|
-
console.warn(`[game-kit] ${message}`);
|
|
1858
|
-
};
|
|
1859
|
-
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1860
|
-
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
1861
|
-
var deepMerge = (base2, patch) => {
|
|
1862
|
-
if (!patch) return base2;
|
|
1863
|
-
const result = { ...base2 };
|
|
1864
|
-
for (const [key2, value] of Object.entries(patch)) {
|
|
1865
|
-
if (value === void 0 || UNSAFE_KEYS.has(key2)) continue;
|
|
1866
|
-
const current = result[key2];
|
|
1867
|
-
result[key2] = isPlainObject(current) && isPlainObject(value) ? deepMerge(current, value) : value;
|
|
1868
|
-
}
|
|
1869
|
-
return result;
|
|
1870
|
-
};
|
|
1871
|
-
var mergeById = (shipped, extra) => {
|
|
1872
|
-
const entries = /* @__PURE__ */ new Map();
|
|
1873
|
-
for (const entry2 of [...shipped, ...extra ?? []]) entries.set(entry2.id, entry2);
|
|
1874
|
-
return entries;
|
|
1875
|
-
};
|
|
1876
|
-
var applyPatches = (entries, patches) => {
|
|
1877
|
-
for (const [id, patch] of Object.entries(patches ?? {})) {
|
|
1878
|
-
const entry2 = entries.get(id);
|
|
1879
|
-
if (entry2) entries.set(id, deepMerge(entry2, patch));
|
|
1880
|
-
else warnOnce(`registry.patch.${id}`, `patch for "${id}" ignored: no entry has that id`);
|
|
1881
|
-
}
|
|
1882
|
-
};
|
|
1883
|
-
var removeIds = (entries, ids) => {
|
|
1884
|
-
for (const id of ids ?? []) {
|
|
1885
|
-
if (!entries.delete(id)) warnOnce(`registry.remove.${id}`, `remove of "${id}" ignored: no entry has that id`);
|
|
1886
|
-
}
|
|
1887
|
-
};
|
|
1888
|
-
var defineCategories = (defs, options = {}) => {
|
|
1889
|
-
const problems = [];
|
|
1890
|
-
const duplicates = (list2) => {
|
|
1891
|
-
const ids = /* @__PURE__ */ new Set();
|
|
1892
|
-
for (const def of list2) {
|
|
1893
|
-
if (ids.has(def.id)) problems.push(`duplicate category "${def.id}"`);
|
|
1894
|
-
ids.add(def.id);
|
|
1895
|
-
}
|
|
1896
|
-
};
|
|
1897
|
-
duplicates(defs);
|
|
1898
|
-
duplicates(options.extra ?? []);
|
|
1899
|
-
const entries = mergeById(defs, options.extra);
|
|
1900
|
-
applyPatches(entries, options.patches);
|
|
1901
|
-
removeIds(entries, options.remove);
|
|
1902
|
-
const chain = (id) => {
|
|
1903
|
-
const path = [];
|
|
1904
|
-
let current = id;
|
|
1905
|
-
while (current !== void 0) {
|
|
1906
|
-
const def = entries.get(current);
|
|
1907
|
-
if (!def) throw new Error(path.length === 0 ? `unknown category "${current}"` : `category "${path[0]}" has unknown parent "${current}"`);
|
|
1908
|
-
if (path.includes(current)) throw new Error(`category cycle: ${[...path, current].reverse().join(" -> ")}`);
|
|
1909
|
-
path.push(current);
|
|
1910
|
-
current = def.extends;
|
|
1911
|
-
}
|
|
1912
|
-
return path.reverse();
|
|
1913
|
-
};
|
|
1914
|
-
const registry = {
|
|
1915
|
-
get: (id) => entries.get(id),
|
|
1916
|
-
has: (id) => entries.has(id),
|
|
1917
|
-
ids: () => [...entries.keys()],
|
|
1918
|
-
chain,
|
|
1919
|
-
defaults: (id) => chain(id).reduce((acc, ancestor) => deepMerge(acc, entries.get(ancestor)?.defaults), {}),
|
|
1920
|
-
requires: (id) => {
|
|
1921
|
-
const out = [];
|
|
1922
|
-
for (const ancestor of chain(id)) for (const contract of entries.get(ancestor)?.requires ?? []) if (!out.includes(contract)) out.push(contract);
|
|
1923
|
-
return out;
|
|
1924
|
-
},
|
|
1925
|
-
isA: (id, ancestorId) => {
|
|
1926
|
-
try {
|
|
1927
|
-
return chain(id).includes(ancestorId);
|
|
1928
|
-
} catch {
|
|
1929
|
-
return false;
|
|
1930
|
-
}
|
|
1931
|
-
},
|
|
1932
|
-
check: () => {
|
|
1933
|
-
const found = [...problems];
|
|
1934
|
-
for (const [id, def] of entries) {
|
|
1935
|
-
if (def.extends !== void 0 && !entries.has(def.extends)) found.push(`category "${id}" extends unknown "${def.extends}"`);
|
|
1936
|
-
else {
|
|
1937
|
-
try {
|
|
1938
|
-
chain(id);
|
|
1939
|
-
} catch (error) {
|
|
1940
|
-
const message = error.message;
|
|
1941
|
-
if (message.startsWith("category cycle") && !found.includes(message)) found.push(message);
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
return found;
|
|
1946
|
-
}
|
|
1947
|
-
};
|
|
1948
|
-
return registry;
|
|
1949
|
-
};
|
|
1950
|
-
var resolveEntry = (registry, entry2, kindField = "kind") => deepMerge(registry.defaults(String(entry2[kindField])), entry2);
|
|
1951
|
-
var KIT_ORIGIN_KEY = "kitOrigin";
|
|
1952
|
-
function markKitOrigin(object2, origin) {
|
|
1953
|
-
const node = object2;
|
|
1954
|
-
node.userData = node.userData ?? {};
|
|
1955
|
-
node.userData[KIT_ORIGIN_KEY] = { ...origin };
|
|
1956
|
-
return object2;
|
|
1957
|
-
}
|
|
1958
|
-
var SURFACE_IDS = ["concrete", "asphalt", "wood", "tile", "dirt", "grass", "gravel", "sand", "metal", "water", "glass", "carpet"];
|
|
1959
|
-
var GAIT_IDS = ["walk", "run"];
|
|
1960
|
-
var LANDING_IDS = ["light", "heavy"];
|
|
1961
|
-
var BODY_SOUND_IDS = [
|
|
1962
|
-
"jump",
|
|
1963
|
-
"cloth_rustle",
|
|
1964
|
-
"body_fall",
|
|
1965
|
-
"fall_damage",
|
|
1966
|
-
"player_hurt",
|
|
1967
|
-
"player_breath_run",
|
|
1968
|
-
"player_death",
|
|
1969
|
-
"bite",
|
|
1970
|
-
"grab",
|
|
1971
|
-
"punch_swing",
|
|
1972
|
-
"punch_hit_body",
|
|
1973
|
-
"punch_hit_face",
|
|
1974
|
-
"punch_hit_object",
|
|
1975
|
-
"kick_swing",
|
|
1976
|
-
"kick_hit",
|
|
1977
|
-
"kick_hit_object",
|
|
1978
|
-
"shove_two_hands",
|
|
1979
|
-
"knife_swing",
|
|
1980
|
-
"knife_stab",
|
|
1981
|
-
"knife_slash",
|
|
1982
|
-
"knife_hit_object",
|
|
1983
|
-
"blunt_swing",
|
|
1984
|
-
"blunt_hit",
|
|
1985
|
-
"blunt_hit_object",
|
|
1986
|
-
"axe_swing",
|
|
1987
|
-
"axe_chop",
|
|
1988
|
-
"axe_hit_object"
|
|
1989
|
-
];
|
|
1990
|
-
var footstepSoundId = (surface, gait) => `footstep_${surface}_${gait}`;
|
|
1991
|
-
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
1992
|
-
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
1993
|
-
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
1994
|
-
var WORKER_KIND_ID = {
|
|
1995
|
-
GROUND_TILES: "destruction.ground-tiles",
|
|
1996
|
-
CROWD_PHYSICS: "crowd.physics",
|
|
1997
|
-
PIECE_BOXES: "destruction.piece-boxes",
|
|
1998
|
-
STATIC_COLLIDERS: "destruction.static-colliders",
|
|
1999
|
-
SHAPES_GENERATE: "shapes.generate",
|
|
2000
|
-
WORLD_REGION: "world.region",
|
|
2001
|
-
VEHICLE_HULL_PLAN: "vehicles.hull-plan"
|
|
2002
|
-
};
|
|
2003
|
-
var WORKER_KIND_DEFAULTS = {
|
|
2004
|
-
[WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
|
|
2005
|
-
[WORKER_KIND_ID.CROWD_PHYSICS]: { lane: "sim", priority: 250, latencyFrames: 1, late: "sync" },
|
|
2006
|
-
[WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
|
|
2007
|
-
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
2008
|
-
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
2009
|
-
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" },
|
|
2010
|
-
[WORKER_KIND_ID.VEHICLE_HULL_PLAN]: { lane: "build", priority: 120, late: "keep-waiting" }
|
|
2011
|
-
};
|
|
2012
|
-
|
|
2013
2014
|
// ../game-shapes/dist/index.js
|
|
2014
2015
|
var SAME_COLOUR = 1 / 512;
|
|
2015
2016
|
var SAME_FACING = 1 - 1e-6;
|
|
@@ -2323,6 +2324,10 @@ var GameItemsThree = (() => {
|
|
|
2323
2324
|
return object2;
|
|
2324
2325
|
};
|
|
2325
2326
|
return {
|
|
2327
|
+
carryHandle: (part) => {
|
|
2328
|
+
part.userData[CARRY_HANDLE_TAG] = true;
|
|
2329
|
+
return part;
|
|
2330
|
+
},
|
|
2326
2331
|
T: T2,
|
|
2327
2332
|
materials,
|
|
2328
2333
|
M,
|
|
@@ -2415,8 +2420,8 @@ var GameItemsThree = (() => {
|
|
|
2415
2420
|
];
|
|
2416
2421
|
var DEFAULT_COLOR = 9080724;
|
|
2417
2422
|
var PI = Math.PI;
|
|
2418
|
-
function shade(color2,
|
|
2419
|
-
const channel = (shift) => Math.max(0, Math.min(255, Math.round((color2 >> shift & 255) *
|
|
2423
|
+
function shade(color2, factor2) {
|
|
2424
|
+
const channel = (shift) => Math.max(0, Math.min(255, Math.round((color2 >> shift & 255) * factor2)));
|
|
2420
2425
|
return channel(16) << 16 | channel(8) << 8 | channel(0);
|
|
2421
2426
|
}
|
|
2422
2427
|
var PROUD = 2e-3;
|
|
@@ -3735,6 +3740,7 @@ var GameItemsThree = (() => {
|
|
|
3735
3740
|
return;
|
|
3736
3741
|
}
|
|
3737
3742
|
const rule = modelId !== void 0 ? itemDestruction(modelId) : shapeId !== void 0 ? shapeDestruction(shapeId) : void 0;
|
|
3743
|
+
const body = options.parts?.length === 1 ? options.parts[0] : void 0;
|
|
3738
3744
|
if (rule?.tessellate) tessellateShapes(root, rule.tessellate, three);
|
|
3739
3745
|
const solid = [];
|
|
3740
3746
|
root.traverse((object2) => {
|
|
@@ -3748,6 +3754,10 @@ var GameItemsThree = (() => {
|
|
|
3748
3754
|
mesh2.userData.destructionSkin = true;
|
|
3749
3755
|
return;
|
|
3750
3756
|
}
|
|
3757
|
+
if (body) {
|
|
3758
|
+
mesh2.userData.destructionMaterial = body.material;
|
|
3759
|
+
if (body.thickness !== void 0) mesh2.userData.destructionThickness = body.thickness;
|
|
3760
|
+
}
|
|
3751
3761
|
if (rule?.hollow) mesh2.userData.hollow = true;
|
|
3752
3762
|
if (powder) mesh2.userData.destructionPowder = { color: powder.color };
|
|
3753
3763
|
solid.push(mesh2);
|
|
@@ -7485,7 +7495,7 @@ var GameItemsThree = (() => {
|
|
|
7485
7495
|
};
|
|
7486
7496
|
|
|
7487
7497
|
// src/models/bucket.ts
|
|
7488
|
-
var bucket = ({ mesh: mesh2, bx, cyl, G, plastic, metal }) => {
|
|
7498
|
+
var bucket = ({ mesh: mesh2, bx, cyl, G, plastic, metal, carryHandle }) => {
|
|
7489
7499
|
const body = plastic(2908062);
|
|
7490
7500
|
const wire = metal(9080209);
|
|
7491
7501
|
return G(
|
|
@@ -7494,7 +7504,7 @@ var GameItemsThree = (() => {
|
|
|
7494
7504
|
mesh2(cyl(11.8, 11.8, 1, 16), plastic(2313602), [0, -13, 0]),
|
|
7495
7505
|
mesh2(bx(0.6, 3.7, 0.6), wire, [13, 11.35, 0]),
|
|
7496
7506
|
mesh2(bx(0.6, 3.7, 0.6), wire, [-13, 11.35, 0]),
|
|
7497
|
-
mesh2(bx(27.2, 0.5, 1.1), wire, [0, 13.25, 0])
|
|
7507
|
+
carryHandle(mesh2(bx(27.2, 0.5, 1.1), wire, [0, 13.25, 0]))
|
|
7498
7508
|
);
|
|
7499
7509
|
};
|
|
7500
7510
|
|
|
@@ -10175,7 +10185,7 @@ var GameItemsThree = (() => {
|
|
|
10175
10185
|
const materials = kit.materials.slice(first);
|
|
10176
10186
|
if (options.wear) setWear(materials, options.wear);
|
|
10177
10187
|
root.userData.wear = options.wear ?? 0;
|
|
10178
|
-
if (options.destructible) tagForDestruction(root, { ...kind === "model" && item.model !== void 0 ? { modelId: item.model } : {}, ...shape === void 0 ? {} : { shapeId: shape }, ...item.weight === void 0 ? {} : { weight: item.weight }, size: item.size, ...item.powder ? { powder: item.powder } : {}, three: T2 });
|
|
10188
|
+
if (options.destructible) tagForDestruction(root, { ...kind === "model" && item.model !== void 0 ? { modelId: item.model } : {}, ...shape === void 0 ? {} : { shapeId: shape }, ...item.weight === void 0 ? {} : { weight: item.weight }, size: item.size, ...item.powder ? { powder: item.powder } : {}, ...item.parts ? { parts: item.parts } : {}, three: T2 });
|
|
10179
10189
|
markKitOrigin(root, { owner: "game-items-three", kind: "item", id: item.id, ...kind === "shape" ? { standIn: true } : {} });
|
|
10180
10190
|
return { root, kind, ...shape ? { shape } : {}, size: item.size, materials };
|
|
10181
10191
|
}
|
|
@@ -12676,63 +12686,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
12676
12686
|
}
|
|
12677
12687
|
|
|
12678
12688
|
// ../game-destruction/dist/index.js
|
|
12679
|
-
var AIR_DENSITY = 1.2;
|
|
12680
|
-
var DRAG_AREA_FACTOR = 1.5;
|
|
12681
|
-
var STEEL_DENSITY = 7850;
|
|
12682
|
-
var FRAGMENT_MIN_SPEED = 30;
|
|
12683
|
-
var GLASS_STIFFENING = 2.5;
|
|
12684
|
-
var PLATE_COEFFICIENT = 0.2874;
|
|
12685
|
-
var BEAM_COEFFICIENT = 0.75;
|
|
12686
|
-
var TNT_PER_JOULE = DEFAULT_BLAST_IMPULSE.tntPerJoule;
|
|
12687
|
-
function projectedArea(shape, toward) {
|
|
12688
|
-
const [dx, dy, dz] = [Math.abs(toward[0]), Math.abs(toward[1]), Math.abs(toward[2])];
|
|
12689
|
-
if (shape.kind === "box") return dx * shape.size[1] * shape.size[2] + dy * shape.size[0] * shape.size[2] + dz * shape.size[0] * shape.size[1];
|
|
12690
|
-
if (shape.kind === "cylinder") return Math.PI * shape.radius ** 2 * dy + 2 * shape.radius * shape.height * Math.sqrt(Math.max(0, 1 - dy * dy));
|
|
12691
|
-
return Math.PI * shape.radius ** 2;
|
|
12692
|
-
}
|
|
12693
|
-
function failureWork(input) {
|
|
12694
|
-
const ratio = input.thickness / Math.max(input.span, input.thickness);
|
|
12695
|
-
const stiffening = input.isGlass ? GLASS_STIFFENING : 1;
|
|
12696
|
-
const pressure = stiffening * input.failureMPa * 1e6 * ratio * ratio / (input.isBeam ? BEAM_COEFFICIENT : PLATE_COEFFICIENT);
|
|
12697
|
-
const deflection = input.thickness * (1 + 25 * input.ductility * input.ductility);
|
|
12698
|
-
return { pressure, work: (0.5 + 0.5 * input.ductility) * pressure * input.loaded * deflection };
|
|
12699
|
-
}
|
|
12700
|
-
function casingFlight(casing) {
|
|
12701
|
-
const k = casing.geometry === "cylinder" ? 0.5 : 0.6;
|
|
12702
|
-
return {
|
|
12703
|
-
mottScale: casing.mass / (2 * Math.max(1, casing.fragments)),
|
|
12704
|
-
speed: casing.gurneyVelocity / Math.sqrt(casing.mass / Math.max(casing.chargeMass, 1e-6) + k)
|
|
12705
|
-
};
|
|
12706
|
-
}
|
|
12707
|
-
function mottMass(u, scale, fragments) {
|
|
12708
|
-
const lowest = 1 / Math.max(1, fragments);
|
|
12709
|
-
return scale * Math.log(1 / Math.max(u, lowest)) ** 2;
|
|
12710
|
-
}
|
|
12711
|
-
function fragmentCaliberMm(mass) {
|
|
12712
|
-
return 2e3 * Math.cbrt(3 * mass / (4 * Math.PI * STEEL_DENSITY));
|
|
12713
|
-
}
|
|
12714
|
-
function fragmentDrag(mass) {
|
|
12715
|
-
const sphereArea = Math.PI * Math.cbrt(3 * mass / (4 * Math.PI * STEEL_DENSITY)) ** 2;
|
|
12716
|
-
return AIR_DENSITY * DRAG_AREA_FACTOR * sphereArea / (2 * mass);
|
|
12717
|
-
}
|
|
12718
|
-
var BLUNT_FRAGMENT_NOSE = 0.84;
|
|
12719
|
-
var NDRC_CONSTANT = 38e-6;
|
|
12720
|
-
function concretePerforation(input) {
|
|
12721
|
-
const { mass, caliber, speed } = input;
|
|
12722
|
-
if (!(mass > 0) || !(caliber > 0) || !(speed > 0)) return { depth: 0, perforation: 0 };
|
|
12723
|
-
const g = NDRC_CONSTANT * (input.nose ?? BLUNT_FRAGMENT_NOSE) * mass / (caliber * Math.sqrt(input.compressiveMPa * 1e6)) * (speed / caliber) ** 1.8;
|
|
12724
|
-
const relative = g <= 1 ? 2 * Math.sqrt(g) : g + 1;
|
|
12725
|
-
const through = relative <= 1.35 ? 3.19 * relative - 0.718 * relative * relative : 1.32 + 1.24 * relative;
|
|
12726
|
-
return { depth: relative * caliber, perforation: through * caliber };
|
|
12727
|
-
}
|
|
12728
|
-
var FIRE_PRIME_C = 300;
|
|
12729
|
-
var drawChainDelay = (delay, random) => {
|
|
12730
|
-
if (typeof delay === "number") return delay;
|
|
12731
|
-
const [min, max] = delay;
|
|
12732
|
-
return min + random() * (max - min);
|
|
12733
|
-
};
|
|
12734
|
-
var chainDelayOf = (spec, trigger) => spec.explodes?.chain?.[trigger];
|
|
12735
|
-
var shotDamageFractionOf = (spec) => spec.explodes?.chain?.shotDamageFraction ?? 0;
|
|
12736
12689
|
var EPS = 1e-9;
|
|
12737
12690
|
var vec = {
|
|
12738
12691
|
add: (a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]],
|
|
@@ -13014,6 +12967,342 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13014
12967
|
}
|
|
13015
12968
|
};
|
|
13016
12969
|
};
|
|
12970
|
+
var planeAxes = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
|
|
12971
|
+
var BREACH_GRID_CAP = 4096;
|
|
12972
|
+
var unitGrid = (dims, thin, units, cap) => {
|
|
12973
|
+
const [u, v] = planeAxes(thin);
|
|
12974
|
+
let unitU = Math.min(units.size[0], dims[u]), unitV = Math.min(units.size[1], dims[v]);
|
|
12975
|
+
const rowsFor = (h) => Math.ceil(dims[v] / h - 1e-9);
|
|
12976
|
+
const colsFor = (w) => Math.ceil(dims[u] / w - 1e-9) + (units.bond === "running" ? 1 : 0);
|
|
12977
|
+
const merge = Math.ceil(Math.sqrt(rowsFor(unitV) * colsFor(unitU) / cap));
|
|
12978
|
+
if (merge > 1) {
|
|
12979
|
+
unitU = Math.min(unitU * merge, dims[u]);
|
|
12980
|
+
unitV = Math.min(unitV * merge, dims[v]);
|
|
12981
|
+
}
|
|
12982
|
+
const cells = [];
|
|
12983
|
+
for (let row = 0; row < rowsFor(unitV); row++) {
|
|
12984
|
+
const v0 = -dims[v] / 2 + row * unitV, v1 = Math.min(v0 + unitV, dims[v] / 2);
|
|
12985
|
+
const shift = units.bond === "running" && row % 2 === 1 ? unitU / 2 : 0;
|
|
12986
|
+
for (let col = 0; col < colsFor(unitU); col++) {
|
|
12987
|
+
const u0 = Math.max(-dims[u] / 2 + col * unitU - shift, -dims[u] / 2), u1 = Math.min(-dims[u] / 2 + (col + 1) * unitU - shift, dims[u] / 2);
|
|
12988
|
+
if (u1 - u0 < 0.01) continue;
|
|
12989
|
+
const center = [0, 0, 0], size = [0, 0, 0];
|
|
12990
|
+
center[u] = (u0 + u1) / 2;
|
|
12991
|
+
center[v] = (v0 + v1) / 2;
|
|
12992
|
+
size[u] = u1 - u0;
|
|
12993
|
+
size[v] = v1 - v0;
|
|
12994
|
+
size[thin] = dims[thin];
|
|
12995
|
+
cells.push({ center, size });
|
|
12996
|
+
}
|
|
12997
|
+
}
|
|
12998
|
+
return cells;
|
|
12999
|
+
};
|
|
13000
|
+
var rowsOfGrid = /* @__PURE__ */ new WeakMap();
|
|
13001
|
+
var unitRowsWithin = (cells, thin, point, radius) => {
|
|
13002
|
+
const [u, v] = planeAxes(thin);
|
|
13003
|
+
if (!Number.isFinite(point[u]) || !Number.isFinite(point[v]) || !Number.isFinite(radius)) return [[0, cells.length]];
|
|
13004
|
+
let rows = rowsOfGrid.get(cells);
|
|
13005
|
+
if (!rows) {
|
|
13006
|
+
const found = [];
|
|
13007
|
+
cells.forEach((cell, i) => {
|
|
13008
|
+
const last = found[found.length - 1];
|
|
13009
|
+
if (last && last.center === cell.center[v] && last.size === cell.size[v]) last.to = i + 1;
|
|
13010
|
+
else found.push({ from: i, to: i + 1, center: cell.center[v], size: cell.size[v] });
|
|
13011
|
+
});
|
|
13012
|
+
rowsOfGrid.set(cells, rows = found);
|
|
13013
|
+
}
|
|
13014
|
+
const ranges = [];
|
|
13015
|
+
for (const row of rows) {
|
|
13016
|
+
if (Math.max(0, Math.abs(point[v] - row.center) - row.size / 2) > radius) continue;
|
|
13017
|
+
const last = ranges[ranges.length - 1];
|
|
13018
|
+
if (last && last[1] === row.from) last[1] = row.to;
|
|
13019
|
+
else ranges.push([row.from, row.to]);
|
|
13020
|
+
}
|
|
13021
|
+
return ranges;
|
|
13022
|
+
};
|
|
13023
|
+
var planeDistance = (cell, thin, point) => {
|
|
13024
|
+
const [u, v] = planeAxes(thin);
|
|
13025
|
+
const du = cell.center[u] - point[u], dv = cell.center[v] - point[v];
|
|
13026
|
+
return Math.sqrt(du * du + dv * dv);
|
|
13027
|
+
};
|
|
13028
|
+
var cellsWithin = (cells, thin, point, radius) => {
|
|
13029
|
+
const inside3 = cells.filter((c) => planeDistance(c, thin, point) <= radius);
|
|
13030
|
+
if (inside3.length > 0 || cells.length === 0) return inside3;
|
|
13031
|
+
return [cells.reduce((best, c) => planeDistance(c, thin, point) < planeDistance(best, thin, point) ? c : best)];
|
|
13032
|
+
};
|
|
13033
|
+
var cellsOutside = (cells, thin, point, radius) => cells.filter((c) => planeDistance(c, thin, point) > radius);
|
|
13034
|
+
var MAX_MARKS_PER_FRAGMENT = 12;
|
|
13035
|
+
var marksInBox = (center, size, rotation, holes) => {
|
|
13036
|
+
const inverse = rotation ? quat.conjugate(rotation) : void 0;
|
|
13037
|
+
const marks = [];
|
|
13038
|
+
for (const hole of holes) {
|
|
13039
|
+
const offset = [hole.point[0] - center[0], hole.point[1] - center[1], hole.point[2] - center[2]];
|
|
13040
|
+
const point = inverse ? rotateVec(inverse, offset) : offset;
|
|
13041
|
+
const inside3 = point.every((value, k) => Math.abs(value) <= size[k] / 2 + hole.diameter / 2);
|
|
13042
|
+
if (!inside3) continue;
|
|
13043
|
+
marks.push({ point, normal: inverse ? rotateVec(inverse, hole.normal) : hole.normal, diameter: hole.diameter });
|
|
13044
|
+
if (marks.length >= MAX_MARKS_PER_FRAGMENT) break;
|
|
13045
|
+
}
|
|
13046
|
+
return marks;
|
|
13047
|
+
};
|
|
13048
|
+
var rowLayouts = /* @__PURE__ */ new WeakMap();
|
|
13049
|
+
var rowLayoutOf = (cells, thin, bottom) => {
|
|
13050
|
+
const known = rowLayouts.get(cells);
|
|
13051
|
+
if (known && known.thin === thin && known.bottom === bottom && known.count === cells.length) return known;
|
|
13052
|
+
const [u, v] = planeAxes(thin);
|
|
13053
|
+
const keys = cells.map((cell) => Math.round((cell.center[v] - cell.size[v] / 2 - bottom) * 1e4));
|
|
13054
|
+
const alongOrder = cells.map((_, i) => i).sort((a, b) => cells[a].center[u] - cells[b].center[u]);
|
|
13055
|
+
const layout = { thin, bottom, count: cells.length, keys, alongOrder };
|
|
13056
|
+
rowLayouts.set(cells, layout);
|
|
13057
|
+
return layout;
|
|
13058
|
+
};
|
|
13059
|
+
var holeInBox = (center, size, hole) => {
|
|
13060
|
+
for (let k = 0; k < 3; k++) if (!(Math.abs(hole.point[k] - center[k]) <= size[k] / 2 + hole.diameter / 2)) return false;
|
|
13061
|
+
return true;
|
|
13062
|
+
};
|
|
13063
|
+
var JOINT_GAP = 1e-4;
|
|
13064
|
+
var MIN_BEARING_SHARE = 0.25;
|
|
13065
|
+
var unsupportedCells = (cells, thin, dims, standing) => {
|
|
13066
|
+
if (thin === 1) return unheldSlabCells(cells, dims, standing);
|
|
13067
|
+
const [u, v] = planeAxes(thin);
|
|
13068
|
+
const bottom = -dims[v] / 2;
|
|
13069
|
+
const layout = rowLayoutOf(cells, thin, bottom);
|
|
13070
|
+
const rows = /* @__PURE__ */ new Map();
|
|
13071
|
+
const isStanding = new Uint8Array(cells.length);
|
|
13072
|
+
for (let i = 0; i < cells.length; i++) {
|
|
13073
|
+
if (!standing(i)) continue;
|
|
13074
|
+
isStanding[i] = 1;
|
|
13075
|
+
const key2 = layout.keys[i];
|
|
13076
|
+
if (!rows.has(key2)) rows.set(key2, []);
|
|
13077
|
+
}
|
|
13078
|
+
for (const i of layout.alongOrder) if (isStanding[i] === 1) rows.get(layout.keys[i]).push(i);
|
|
13079
|
+
const rowOf = (y) => Math.round((y - bottom) * 1e4);
|
|
13080
|
+
const held = /* @__PURE__ */ new Set();
|
|
13081
|
+
const queue = [];
|
|
13082
|
+
for (const i of rows.get(0) ?? []) {
|
|
13083
|
+
held.add(i);
|
|
13084
|
+
queue.push(i);
|
|
13085
|
+
}
|
|
13086
|
+
const overlap = (a, b) => Math.min(a.center[u] + a.size[u] / 2, b.center[u] + b.size[u] / 2) - Math.max(a.center[u] - a.size[u] / 2, b.center[u] - b.size[u] / 2);
|
|
13087
|
+
const climb = () => {
|
|
13088
|
+
while (queue.length > 0) {
|
|
13089
|
+
const cell = cells[queue.pop()];
|
|
13090
|
+
for (const j of rows.get(rowOf(cell.center[v] + cell.size[v] / 2)) ?? []) {
|
|
13091
|
+
const other = cells[j];
|
|
13092
|
+
if (held.has(j) || overlap(cell, other) <= Math.max(JOINT_GAP, MIN_BEARING_SHARE * Math.min(cell.size[u], other.size[u]))) continue;
|
|
13093
|
+
held.add(j);
|
|
13094
|
+
queue.push(j);
|
|
13095
|
+
}
|
|
13096
|
+
}
|
|
13097
|
+
};
|
|
13098
|
+
const touching = (a, b) => Math.abs(a.center[u] + a.size[u] / 2 - (b.center[u] - b.size[u] / 2)) <= 1e-3;
|
|
13099
|
+
for (let wedged = true; wedged; ) {
|
|
13100
|
+
climb();
|
|
13101
|
+
wedged = false;
|
|
13102
|
+
for (const row of rows.values()) {
|
|
13103
|
+
for (let k = 1; k < row.length - 1; k++) {
|
|
13104
|
+
const i = row[k];
|
|
13105
|
+
if (held.has(i) || !held.has(row[k - 1]) || !held.has(row[k + 1])) continue;
|
|
13106
|
+
if (!touching(cells[row[k - 1]], cells[i]) || !touching(cells[i], cells[row[k + 1]])) continue;
|
|
13107
|
+
held.add(i);
|
|
13108
|
+
queue.push(i);
|
|
13109
|
+
wedged = true;
|
|
13110
|
+
}
|
|
13111
|
+
}
|
|
13112
|
+
}
|
|
13113
|
+
const loose = [];
|
|
13114
|
+
for (const row of rows.values()) for (const i of row) if (!held.has(i)) loose.push(i);
|
|
13115
|
+
return loose;
|
|
13116
|
+
};
|
|
13117
|
+
var slabGrids = /* @__PURE__ */ new WeakMap();
|
|
13118
|
+
function slabGridOf(cells) {
|
|
13119
|
+
const known = slabGrids.get(cells);
|
|
13120
|
+
if (known && known.place.length === cells.length * 2) return known;
|
|
13121
|
+
const [u, v] = planeAxes(1);
|
|
13122
|
+
const round3 = (x) => Math.round(x * 1e4);
|
|
13123
|
+
const columns = [...new Set(cells.map((cell) => round3(cell.center[u])))].sort((a, b) => a - b);
|
|
13124
|
+
const rows = [...new Set(cells.map((cell) => round3(cell.center[v])))].sort((a, b) => a - b);
|
|
13125
|
+
const columnOf = new Map(columns.map((c, k) => [c, k])), rowOf = new Map(rows.map((r, k) => [r, k]));
|
|
13126
|
+
const place = new Int32Array(cells.length * 2);
|
|
13127
|
+
cells.forEach((cell, i) => {
|
|
13128
|
+
place[i * 2] = columnOf.get(round3(cell.center[u]));
|
|
13129
|
+
place[i * 2 + 1] = rowOf.get(round3(cell.center[v]));
|
|
13130
|
+
});
|
|
13131
|
+
const grid = { columns: columns.length, rows: rows.length, place };
|
|
13132
|
+
slabGrids.set(cells, grid);
|
|
13133
|
+
return grid;
|
|
13134
|
+
}
|
|
13135
|
+
var unheldSlabCells = (cells, dims, standing) => {
|
|
13136
|
+
const [u, v] = planeAxes(1);
|
|
13137
|
+
const edge = (cell) => cell.center[u] - cell.size[u] / 2 <= -dims[u] / 2 + JOINT_GAP || cell.center[u] + cell.size[u] / 2 >= dims[u] / 2 - JOINT_GAP || cell.center[v] - cell.size[v] / 2 <= -dims[v] / 2 + JOINT_GAP || cell.center[v] + cell.size[v] / 2 >= dims[v] / 2 - JOINT_GAP;
|
|
13138
|
+
const { columns, rows, place } = slabGridOf(cells);
|
|
13139
|
+
const at2 = /* @__PURE__ */ new Map();
|
|
13140
|
+
for (let i = 0; i < cells.length; i++) if (standing(i)) at2.set(place[i * 2 + 1] * columns + place[i * 2], i);
|
|
13141
|
+
const held = new Uint8Array(cells.length);
|
|
13142
|
+
const queue = [];
|
|
13143
|
+
for (const i of at2.values()) if (edge(cells[i])) {
|
|
13144
|
+
held[i] = 1;
|
|
13145
|
+
queue.push(i);
|
|
13146
|
+
}
|
|
13147
|
+
while (queue.length > 0) {
|
|
13148
|
+
const i = queue.pop();
|
|
13149
|
+
const c = place[i * 2], r = place[i * 2 + 1];
|
|
13150
|
+
for (const [nc, nr] of [[c - 1, r], [c + 1, r], [c, r - 1], [c, r + 1]]) {
|
|
13151
|
+
if (nc < 0 || nr < 0 || nc >= columns || nr >= rows) continue;
|
|
13152
|
+
const j = at2.get(nr * columns + nc);
|
|
13153
|
+
if (j === void 0 || held[j] === 1) continue;
|
|
13154
|
+
held[j] = 1;
|
|
13155
|
+
queue.push(j);
|
|
13156
|
+
}
|
|
13157
|
+
}
|
|
13158
|
+
const loose = [];
|
|
13159
|
+
for (const i of at2.values()) if (held[i] !== 1) loose.push(i);
|
|
13160
|
+
return loose.sort((a, b) => a - b);
|
|
13161
|
+
};
|
|
13162
|
+
var clumpUnits = (cells, thin, unit, cap) => {
|
|
13163
|
+
if (cells.length <= cap) return [...cells];
|
|
13164
|
+
const [u, v] = planeAxes(thin);
|
|
13165
|
+
let lo0 = Infinity, lo1 = Infinity;
|
|
13166
|
+
for (const cell of cells) {
|
|
13167
|
+
lo0 = Math.min(lo0, cell.center[u] - cell.size[u] / 2);
|
|
13168
|
+
lo1 = Math.min(lo1, cell.center[v] - cell.size[v] / 2);
|
|
13169
|
+
}
|
|
13170
|
+
let along2 = 1, up = 1;
|
|
13171
|
+
for (let grow = 0; ; grow++) {
|
|
13172
|
+
const bins = /* @__PURE__ */ new Map();
|
|
13173
|
+
for (const cell of cells) {
|
|
13174
|
+
const key2 = `${Math.floor((cell.center[u] - lo0) / (along2 * unit[0]))}:${Math.floor((cell.center[v] - lo1) / (up * unit[1]))}`;
|
|
13175
|
+
const bin2 = bins.get(key2) ?? { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] };
|
|
13176
|
+
for (let k = 0; k < 3; k++) {
|
|
13177
|
+
bin2.lo[k] = Math.min(bin2.lo[k], cell.center[k] - cell.size[k] / 2);
|
|
13178
|
+
bin2.hi[k] = Math.max(bin2.hi[k], cell.center[k] + cell.size[k] / 2);
|
|
13179
|
+
}
|
|
13180
|
+
bins.set(key2, bin2);
|
|
13181
|
+
}
|
|
13182
|
+
if (bins.size <= cap) {
|
|
13183
|
+
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]] }));
|
|
13184
|
+
}
|
|
13185
|
+
if (grow % 2 === 0) up++;
|
|
13186
|
+
else along2++;
|
|
13187
|
+
}
|
|
13188
|
+
};
|
|
13189
|
+
var MAX_SPALLS = 64;
|
|
13190
|
+
var thinAxisOf = (dims) => dims[0] <= dims[1] && dims[0] <= dims[2] ? 0 : dims[1] <= dims[2] ? 1 : 2;
|
|
13191
|
+
var resolveLayer = (def, index, mat) => ({ index, def, mat, energy: mat.penetration * def.thickness * 1e3 });
|
|
13192
|
+
var faceCode = (thin, axis, sign2) => {
|
|
13193
|
+
const [u] = planeAxes(thin);
|
|
13194
|
+
return (sign2 >= 0 ? 1 : -1) * (axis === thin ? 1 : axis === u ? 2 : 3);
|
|
13195
|
+
};
|
|
13196
|
+
var faceAxis = (thin, face) => {
|
|
13197
|
+
const k = Math.abs(face);
|
|
13198
|
+
return k === 1 ? thin : planeAxes(thin)[k - 2];
|
|
13199
|
+
};
|
|
13200
|
+
var faceOfNormal = (layers, thin, localNormal) => {
|
|
13201
|
+
if (!layers.some((l) => l.def.faces === "all")) return localNormal[thin] >= 0 ? 1 : -1;
|
|
13202
|
+
let axis = thin;
|
|
13203
|
+
for (let k = 0; k < 3; k++) if (Math.abs(localNormal[k]) > Math.abs(localNormal[axis])) axis = k;
|
|
13204
|
+
return faceCode(thin, axis, localNormal[axis]);
|
|
13205
|
+
};
|
|
13206
|
+
var onFace = (layer, face) => {
|
|
13207
|
+
const faces = layer.def.faces;
|
|
13208
|
+
if (faces === "all") return true;
|
|
13209
|
+
if (Math.abs(face) !== 1) return false;
|
|
13210
|
+
return faces === "both" || faces === (face > 0 ? "+" : "-");
|
|
13211
|
+
};
|
|
13212
|
+
var thinSidesOf = (def) => def.faces === "both" || def.faces === "all" ? [1, -1] : [def.faces === "+" ? 1 : -1];
|
|
13213
|
+
var isSpalled = (spalls, layer, face, point) => {
|
|
13214
|
+
for (const s of spalls ?? []) {
|
|
13215
|
+
if (s[0] !== layer || s[1] !== face) continue;
|
|
13216
|
+
const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
|
|
13217
|
+
if (dx * dx + dy * dy + dz * dz <= s[5] * s[5]) return true;
|
|
13218
|
+
}
|
|
13219
|
+
return false;
|
|
13220
|
+
};
|
|
13221
|
+
var outerLayer = (layers, spalls, face, point) => layers.find((l) => onFace(l, face) && !isSpalled(spalls, l.index, face, point));
|
|
13222
|
+
var layersEnergy = (layers, spalls, face, point) => {
|
|
13223
|
+
let sum = 0;
|
|
13224
|
+
for (const l of layers) if (onFace(l, face) && !isSpalled(spalls, l.index, face, point)) sum += l.energy;
|
|
13225
|
+
return sum;
|
|
13226
|
+
};
|
|
13227
|
+
var layersThickness = (layers, face) => {
|
|
13228
|
+
let sum = 0;
|
|
13229
|
+
for (const l of layers) if (onFace(l, face)) sum += l.def.thickness;
|
|
13230
|
+
return sum;
|
|
13231
|
+
};
|
|
13232
|
+
var tornPatchAt = (layers, spalls, face, point, radius) => {
|
|
13233
|
+
for (const l of layers) {
|
|
13234
|
+
if (!onFace(l, face)) continue;
|
|
13235
|
+
if (l.mat.fracture === "tear") {
|
|
13236
|
+
let best = -1;
|
|
13237
|
+
(spalls ?? []).forEach((s, i) => {
|
|
13238
|
+
if (s[0] !== l.index || s[1] !== face) return;
|
|
13239
|
+
const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
|
|
13240
|
+
const reach2 = s[5] + radius;
|
|
13241
|
+
if (dx * dx + dy * dy + dz * dz <= reach2 * reach2 && (best < 0 || s[5] > spalls[best][5])) best = i;
|
|
13242
|
+
});
|
|
13243
|
+
if (best >= 0) return { layer: l, spall: best };
|
|
13244
|
+
}
|
|
13245
|
+
if (!isSpalled(spalls, l.index, face, point)) return void 0;
|
|
13246
|
+
}
|
|
13247
|
+
return void 0;
|
|
13248
|
+
};
|
|
13249
|
+
var AIR_DENSITY = 1.2;
|
|
13250
|
+
var DRAG_AREA_FACTOR = 1.5;
|
|
13251
|
+
var STEEL_DENSITY = 7850;
|
|
13252
|
+
var FRAGMENT_MIN_SPEED = 30;
|
|
13253
|
+
var GLASS_STIFFENING = 2.5;
|
|
13254
|
+
var PLATE_COEFFICIENT = 0.2874;
|
|
13255
|
+
var BEAM_COEFFICIENT = 0.75;
|
|
13256
|
+
var TNT_PER_JOULE = DEFAULT_BLAST_IMPULSE.tntPerJoule;
|
|
13257
|
+
function projectedArea(shape, toward) {
|
|
13258
|
+
const [dx, dy, dz] = [Math.abs(toward[0]), Math.abs(toward[1]), Math.abs(toward[2])];
|
|
13259
|
+
if (shape.kind === "box") return dx * shape.size[1] * shape.size[2] + dy * shape.size[0] * shape.size[2] + dz * shape.size[0] * shape.size[1];
|
|
13260
|
+
if (shape.kind === "cylinder") return Math.PI * shape.radius ** 2 * dy + 2 * shape.radius * shape.height * Math.sqrt(Math.max(0, 1 - dy * dy));
|
|
13261
|
+
return Math.PI * shape.radius ** 2;
|
|
13262
|
+
}
|
|
13263
|
+
function failureWork(input) {
|
|
13264
|
+
const ratio = input.thickness / Math.max(input.span, input.thickness);
|
|
13265
|
+
const stiffening = input.isGlass ? GLASS_STIFFENING : 1;
|
|
13266
|
+
const pressure = stiffening * input.failureMPa * 1e6 * ratio * ratio / (input.isBeam ? BEAM_COEFFICIENT : PLATE_COEFFICIENT);
|
|
13267
|
+
const deflection = input.thickness * (1 + 25 * input.ductility * input.ductility);
|
|
13268
|
+
return { pressure, work: (0.5 + 0.5 * input.ductility) * pressure * input.loaded * deflection };
|
|
13269
|
+
}
|
|
13270
|
+
function casingFlight(casing) {
|
|
13271
|
+
const k = casing.geometry === "cylinder" ? 0.5 : 0.6;
|
|
13272
|
+
return {
|
|
13273
|
+
mottScale: casing.mass / (2 * Math.max(1, casing.fragments)),
|
|
13274
|
+
speed: casing.gurneyVelocity / Math.sqrt(casing.mass / Math.max(casing.chargeMass, 1e-6) + k)
|
|
13275
|
+
};
|
|
13276
|
+
}
|
|
13277
|
+
function mottMass(u, scale, fragments) {
|
|
13278
|
+
const lowest = 1 / Math.max(1, fragments);
|
|
13279
|
+
return scale * Math.log(1 / Math.max(u, lowest)) ** 2;
|
|
13280
|
+
}
|
|
13281
|
+
function fragmentCaliberMm(mass) {
|
|
13282
|
+
return 2e3 * Math.cbrt(3 * mass / (4 * Math.PI * STEEL_DENSITY));
|
|
13283
|
+
}
|
|
13284
|
+
function fragmentDrag(mass) {
|
|
13285
|
+
const sphereArea = Math.PI * Math.cbrt(3 * mass / (4 * Math.PI * STEEL_DENSITY)) ** 2;
|
|
13286
|
+
return AIR_DENSITY * DRAG_AREA_FACTOR * sphereArea / (2 * mass);
|
|
13287
|
+
}
|
|
13288
|
+
var BLUNT_FRAGMENT_NOSE = 0.84;
|
|
13289
|
+
var NDRC_CONSTANT = 38e-6;
|
|
13290
|
+
function concretePerforation(input) {
|
|
13291
|
+
const { mass, caliber, speed } = input;
|
|
13292
|
+
if (!(mass > 0) || !(caliber > 0) || !(speed > 0)) return { depth: 0, perforation: 0 };
|
|
13293
|
+
const g = NDRC_CONSTANT * (input.nose ?? BLUNT_FRAGMENT_NOSE) * mass / (caliber * Math.sqrt(input.compressiveMPa * 1e6)) * (speed / caliber) ** 1.8;
|
|
13294
|
+
const relative = g <= 1 ? 2 * Math.sqrt(g) : g + 1;
|
|
13295
|
+
const through = relative <= 1.35 ? 3.19 * relative - 0.718 * relative * relative : 1.32 + 1.24 * relative;
|
|
13296
|
+
return { depth: relative * caliber, perforation: through * caliber };
|
|
13297
|
+
}
|
|
13298
|
+
var FIRE_PRIME_C = 300;
|
|
13299
|
+
var drawChainDelay = (delay, random) => {
|
|
13300
|
+
if (typeof delay === "number") return delay;
|
|
13301
|
+
const [min, max] = delay;
|
|
13302
|
+
return min + random() * (max - min);
|
|
13303
|
+
};
|
|
13304
|
+
var chainDelayOf = (spec, trigger) => spec.explodes?.chain?.[trigger];
|
|
13305
|
+
var shotDamageFractionOf = (spec) => spec.explodes?.chain?.shotDamageFraction ?? 0;
|
|
13017
13306
|
var bsp = (root, count, axes, rnd) => {
|
|
13018
13307
|
const pieces = [root];
|
|
13019
13308
|
const vol = (b) => axes.reduce((v, a) => v * b.s[a], 1);
|
|
@@ -13294,179 +13583,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13294
13583
|
const n = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 6, maxFragments);
|
|
13295
13584
|
return radialPlates(inp, root, { t, u, v }, n, Math.min(inp.thickness, dims[t]), fmax * 1.5);
|
|
13296
13585
|
};
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
|
|
13308
|
-
const cells = [];
|
|
13309
|
-
for (let row = 0; row < rowsFor(unitV); row++) {
|
|
13310
|
-
const v0 = -dims[v] / 2 + row * unitV, v1 = Math.min(v0 + unitV, dims[v] / 2);
|
|
13311
|
-
const shift = units.bond === "running" && row % 2 === 1 ? unitU / 2 : 0;
|
|
13312
|
-
for (let col = 0; col < colsFor(unitU); col++) {
|
|
13313
|
-
const u0 = Math.max(-dims[u] / 2 + col * unitU - shift, -dims[u] / 2), u1 = Math.min(-dims[u] / 2 + (col + 1) * unitU - shift, dims[u] / 2);
|
|
13314
|
-
if (u1 - u0 < 0.01) continue;
|
|
13315
|
-
const center = [0, 0, 0], size = [0, 0, 0];
|
|
13316
|
-
center[u] = (u0 + u1) / 2;
|
|
13317
|
-
center[v] = (v0 + v1) / 2;
|
|
13318
|
-
size[u] = u1 - u0;
|
|
13319
|
-
size[v] = v1 - v0;
|
|
13320
|
-
size[thin] = dims[thin];
|
|
13321
|
-
cells.push({ center, size });
|
|
13322
|
-
}
|
|
13323
|
-
}
|
|
13324
|
-
return cells;
|
|
13325
|
-
};
|
|
13326
|
-
var rowsOfGrid = /* @__PURE__ */ new WeakMap();
|
|
13327
|
-
var unitRowsWithin = (cells, thin, point, radius) => {
|
|
13328
|
-
const [u, v] = planeAxes(thin);
|
|
13329
|
-
if (!Number.isFinite(point[u]) || !Number.isFinite(point[v]) || !Number.isFinite(radius)) return [[0, cells.length]];
|
|
13330
|
-
let rows = rowsOfGrid.get(cells);
|
|
13331
|
-
if (!rows) {
|
|
13332
|
-
const found = [];
|
|
13333
|
-
cells.forEach((cell, i) => {
|
|
13334
|
-
const last = found[found.length - 1];
|
|
13335
|
-
if (last && last.center === cell.center[v] && last.size === cell.size[v]) last.to = i + 1;
|
|
13336
|
-
else found.push({ from: i, to: i + 1, center: cell.center[v], size: cell.size[v] });
|
|
13337
|
-
});
|
|
13338
|
-
rowsOfGrid.set(cells, rows = found);
|
|
13339
|
-
}
|
|
13340
|
-
const ranges = [];
|
|
13341
|
-
for (const row of rows) {
|
|
13342
|
-
if (Math.max(0, Math.abs(point[v] - row.center) - row.size / 2) > radius) continue;
|
|
13343
|
-
const last = ranges[ranges.length - 1];
|
|
13344
|
-
if (last && last[1] === row.from) last[1] = row.to;
|
|
13345
|
-
else ranges.push([row.from, row.to]);
|
|
13346
|
-
}
|
|
13347
|
-
return ranges;
|
|
13348
|
-
};
|
|
13349
|
-
var planeDistance = (cell, thin, point) => {
|
|
13350
|
-
const [u, v] = planeAxes(thin);
|
|
13351
|
-
const du = cell.center[u] - point[u], dv = cell.center[v] - point[v];
|
|
13352
|
-
return Math.sqrt(du * du + dv * dv);
|
|
13353
|
-
};
|
|
13354
|
-
var cellsWithin = (cells, thin, point, radius) => {
|
|
13355
|
-
const inside3 = cells.filter((c) => planeDistance(c, thin, point) <= radius);
|
|
13356
|
-
if (inside3.length > 0 || cells.length === 0) return inside3;
|
|
13357
|
-
return [cells.reduce((best, c) => planeDistance(c, thin, point) < planeDistance(best, thin, point) ? c : best)];
|
|
13358
|
-
};
|
|
13359
|
-
var cellsOutside = (cells, thin, point, radius) => cells.filter((c) => planeDistance(c, thin, point) > radius);
|
|
13360
|
-
var MAX_MARKS_PER_FRAGMENT = 12;
|
|
13361
|
-
var marksInBox = (center, size, rotation, holes) => {
|
|
13362
|
-
const inverse = rotation ? quat.conjugate(rotation) : void 0;
|
|
13363
|
-
const marks = [];
|
|
13364
|
-
for (const hole of holes) {
|
|
13365
|
-
const offset = [hole.point[0] - center[0], hole.point[1] - center[1], hole.point[2] - center[2]];
|
|
13366
|
-
const point = inverse ? rotateVec(inverse, offset) : offset;
|
|
13367
|
-
const inside3 = point.every((value, k) => Math.abs(value) <= size[k] / 2 + hole.diameter / 2);
|
|
13368
|
-
if (!inside3) continue;
|
|
13369
|
-
marks.push({ point, normal: inverse ? rotateVec(inverse, hole.normal) : hole.normal, diameter: hole.diameter });
|
|
13370
|
-
if (marks.length >= MAX_MARKS_PER_FRAGMENT) break;
|
|
13371
|
-
}
|
|
13372
|
-
return marks;
|
|
13373
|
-
};
|
|
13374
|
-
var rowLayouts = /* @__PURE__ */ new WeakMap();
|
|
13375
|
-
var rowLayoutOf = (cells, thin, bottom) => {
|
|
13376
|
-
const known = rowLayouts.get(cells);
|
|
13377
|
-
if (known && known.thin === thin && known.bottom === bottom && known.count === cells.length) return known;
|
|
13378
|
-
const [u, v] = planeAxes(thin);
|
|
13379
|
-
const keys = cells.map((cell) => Math.round((cell.center[v] - cell.size[v] / 2 - bottom) * 1e4));
|
|
13380
|
-
const alongOrder = cells.map((_, i) => i).sort((a, b) => cells[a].center[u] - cells[b].center[u]);
|
|
13381
|
-
const layout = { thin, bottom, count: cells.length, keys, alongOrder };
|
|
13382
|
-
rowLayouts.set(cells, layout);
|
|
13383
|
-
return layout;
|
|
13384
|
-
};
|
|
13385
|
-
var holeInBox = (center, size, hole) => {
|
|
13386
|
-
for (let k = 0; k < 3; k++) if (!(Math.abs(hole.point[k] - center[k]) <= size[k] / 2 + hole.diameter / 2)) return false;
|
|
13387
|
-
return true;
|
|
13388
|
-
};
|
|
13389
|
-
var JOINT_GAP = 1e-4;
|
|
13390
|
-
var MIN_BEARING_SHARE = 0.25;
|
|
13391
|
-
var unsupportedCells = (cells, thin, dims, standing) => {
|
|
13392
|
-
if (thin === 1) return [];
|
|
13393
|
-
const [u, v] = planeAxes(thin);
|
|
13394
|
-
const bottom = -dims[v] / 2;
|
|
13395
|
-
const layout = rowLayoutOf(cells, thin, bottom);
|
|
13396
|
-
const rows = /* @__PURE__ */ new Map();
|
|
13397
|
-
const isStanding = new Uint8Array(cells.length);
|
|
13398
|
-
for (let i = 0; i < cells.length; i++) {
|
|
13399
|
-
if (!standing(i)) continue;
|
|
13400
|
-
isStanding[i] = 1;
|
|
13401
|
-
const key2 = layout.keys[i];
|
|
13402
|
-
if (!rows.has(key2)) rows.set(key2, []);
|
|
13403
|
-
}
|
|
13404
|
-
for (const i of layout.alongOrder) if (isStanding[i] === 1) rows.get(layout.keys[i]).push(i);
|
|
13405
|
-
const rowOf = (y) => Math.round((y - bottom) * 1e4);
|
|
13406
|
-
const held = /* @__PURE__ */ new Set();
|
|
13407
|
-
const queue = [];
|
|
13408
|
-
for (const i of rows.get(0) ?? []) {
|
|
13409
|
-
held.add(i);
|
|
13410
|
-
queue.push(i);
|
|
13411
|
-
}
|
|
13412
|
-
const overlap = (a, b) => Math.min(a.center[u] + a.size[u] / 2, b.center[u] + b.size[u] / 2) - Math.max(a.center[u] - a.size[u] / 2, b.center[u] - b.size[u] / 2);
|
|
13413
|
-
const climb = () => {
|
|
13414
|
-
while (queue.length > 0) {
|
|
13415
|
-
const cell = cells[queue.pop()];
|
|
13416
|
-
for (const j of rows.get(rowOf(cell.center[v] + cell.size[v] / 2)) ?? []) {
|
|
13417
|
-
const other = cells[j];
|
|
13418
|
-
if (held.has(j) || overlap(cell, other) <= Math.max(JOINT_GAP, MIN_BEARING_SHARE * Math.min(cell.size[u], other.size[u]))) continue;
|
|
13419
|
-
held.add(j);
|
|
13420
|
-
queue.push(j);
|
|
13421
|
-
}
|
|
13422
|
-
}
|
|
13423
|
-
};
|
|
13424
|
-
const touching = (a, b) => Math.abs(a.center[u] + a.size[u] / 2 - (b.center[u] - b.size[u] / 2)) <= 1e-3;
|
|
13425
|
-
for (let wedged = true; wedged; ) {
|
|
13426
|
-
climb();
|
|
13427
|
-
wedged = false;
|
|
13428
|
-
for (const row of rows.values()) {
|
|
13429
|
-
for (let k = 1; k < row.length - 1; k++) {
|
|
13430
|
-
const i = row[k];
|
|
13431
|
-
if (held.has(i) || !held.has(row[k - 1]) || !held.has(row[k + 1])) continue;
|
|
13432
|
-
if (!touching(cells[row[k - 1]], cells[i]) || !touching(cells[i], cells[row[k + 1]])) continue;
|
|
13433
|
-
held.add(i);
|
|
13434
|
-
queue.push(i);
|
|
13435
|
-
wedged = true;
|
|
13436
|
-
}
|
|
13437
|
-
}
|
|
13438
|
-
}
|
|
13439
|
-
const loose = [];
|
|
13440
|
-
for (const row of rows.values()) for (const i of row) if (!held.has(i)) loose.push(i);
|
|
13441
|
-
return loose;
|
|
13442
|
-
};
|
|
13443
|
-
var clumpUnits = (cells, thin, unit, cap) => {
|
|
13444
|
-
if (cells.length <= cap) return [...cells];
|
|
13445
|
-
const [u, v] = planeAxes(thin);
|
|
13446
|
-
let lo0 = Infinity, lo1 = Infinity;
|
|
13447
|
-
for (const cell of cells) {
|
|
13448
|
-
lo0 = Math.min(lo0, cell.center[u] - cell.size[u] / 2);
|
|
13449
|
-
lo1 = Math.min(lo1, cell.center[v] - cell.size[v] / 2);
|
|
13450
|
-
}
|
|
13451
|
-
let along2 = 1, up = 1;
|
|
13452
|
-
for (let grow = 0; ; grow++) {
|
|
13453
|
-
const bins = /* @__PURE__ */ new Map();
|
|
13454
|
-
for (const cell of cells) {
|
|
13455
|
-
const key2 = `${Math.floor((cell.center[u] - lo0) / (along2 * unit[0]))}:${Math.floor((cell.center[v] - lo1) / (up * unit[1]))}`;
|
|
13456
|
-
const bin2 = bins.get(key2) ?? { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] };
|
|
13457
|
-
for (let k = 0; k < 3; k++) {
|
|
13458
|
-
bin2.lo[k] = Math.min(bin2.lo[k], cell.center[k] - cell.size[k] / 2);
|
|
13459
|
-
bin2.hi[k] = Math.max(bin2.hi[k], cell.center[k] + cell.size[k] / 2);
|
|
13460
|
-
}
|
|
13461
|
-
bins.set(key2, bin2);
|
|
13462
|
-
}
|
|
13463
|
-
if (bins.size <= cap) {
|
|
13464
|
-
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]] }));
|
|
13586
|
+
function put(out, at2, value) {
|
|
13587
|
+
if (at2 < out.length) out[at2] = value;
|
|
13588
|
+
else out.push(value);
|
|
13589
|
+
}
|
|
13590
|
+
function sortFirst(out, count) {
|
|
13591
|
+
for (let i = 1; i < count; i++) {
|
|
13592
|
+
const value = out[i];
|
|
13593
|
+
let j = i - 1;
|
|
13594
|
+
while (j >= 0 && out[j] > value) {
|
|
13595
|
+
out[j + 1] = out[j];
|
|
13596
|
+
j--;
|
|
13465
13597
|
}
|
|
13466
|
-
|
|
13467
|
-
else along2++;
|
|
13598
|
+
out[j + 1] = value;
|
|
13468
13599
|
}
|
|
13469
|
-
}
|
|
13600
|
+
}
|
|
13470
13601
|
var PART_GRID_MIN_PARTS = 64;
|
|
13471
13602
|
var MAX_CELLS_PER_AXIS = 64;
|
|
13472
13603
|
var PAD = 1e-4;
|
|
@@ -13483,8 +13614,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13483
13614
|
if (![...min, ...max].every(Number.isFinite)) {
|
|
13484
13615
|
return {
|
|
13485
13616
|
candidates(_origin, _direction, _maxDistance, out) {
|
|
13486
|
-
|
|
13487
|
-
|
|
13617
|
+
for (let index = 0; index < parts2.length; index++) put(out, index, index);
|
|
13618
|
+
return parts2.length;
|
|
13488
13619
|
}
|
|
13489
13620
|
};
|
|
13490
13621
|
}
|
|
@@ -13524,20 +13655,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13524
13655
|
let stamp = 0;
|
|
13525
13656
|
return {
|
|
13526
13657
|
candidates(origin, direction, maxDistance, out) {
|
|
13527
|
-
|
|
13658
|
+
let count = 0;
|
|
13528
13659
|
let t0 = 0;
|
|
13529
13660
|
let t1 = maxDistance;
|
|
13530
13661
|
for (let k = 0; k < 3; k++) {
|
|
13531
13662
|
const d = direction[k];
|
|
13532
13663
|
if (Math.abs(d) < 1e-12) {
|
|
13533
|
-
if (origin[k] < min[k] || origin[k] > max[k]) return;
|
|
13664
|
+
if (origin[k] < min[k] || origin[k] > max[k]) return 0;
|
|
13534
13665
|
continue;
|
|
13535
13666
|
}
|
|
13536
13667
|
const a = (min[k] - origin[k]) / d;
|
|
13537
13668
|
const b = (max[k] - origin[k]) / d;
|
|
13538
13669
|
t0 = Math.max(t0, Math.min(a, b));
|
|
13539
13670
|
t1 = Math.min(t1, Math.max(a, b));
|
|
13540
|
-
if (t0 > t1) return;
|
|
13671
|
+
if (t0 > t1) return 0;
|
|
13541
13672
|
}
|
|
13542
13673
|
stamp++;
|
|
13543
13674
|
if (stamp === 4294967295) {
|
|
@@ -13557,7 +13688,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13557
13688
|
const index = items[k];
|
|
13558
13689
|
if (seen[index] === stamp) continue;
|
|
13559
13690
|
seen[index] = stamp;
|
|
13560
|
-
out
|
|
13691
|
+
put(out, count++, index);
|
|
13561
13692
|
}
|
|
13562
13693
|
if (nx <= ny && nx <= nz) {
|
|
13563
13694
|
if (nx > t1) break;
|
|
@@ -13576,70 +13707,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13576
13707
|
nz += ez;
|
|
13577
13708
|
}
|
|
13578
13709
|
}
|
|
13579
|
-
|
|
13710
|
+
sortFirst(out, count);
|
|
13711
|
+
return count;
|
|
13580
13712
|
}
|
|
13581
13713
|
};
|
|
13582
13714
|
}
|
|
13583
|
-
var MAX_SPALLS = 64;
|
|
13584
|
-
var thinAxisOf = (dims) => dims[0] <= dims[1] && dims[0] <= dims[2] ? 0 : dims[1] <= dims[2] ? 1 : 2;
|
|
13585
|
-
var resolveLayer = (def, index, mat) => ({ index, def, mat, energy: mat.penetration * def.thickness * 1e3 });
|
|
13586
|
-
var faceCode = (thin, axis, sign2) => {
|
|
13587
|
-
const [u] = planeAxes(thin);
|
|
13588
|
-
return (sign2 >= 0 ? 1 : -1) * (axis === thin ? 1 : axis === u ? 2 : 3);
|
|
13589
|
-
};
|
|
13590
|
-
var faceAxis = (thin, face) => {
|
|
13591
|
-
const k = Math.abs(face);
|
|
13592
|
-
return k === 1 ? thin : planeAxes(thin)[k - 2];
|
|
13593
|
-
};
|
|
13594
|
-
var faceOfNormal = (layers, thin, localNormal) => {
|
|
13595
|
-
if (!layers.some((l) => l.def.faces === "all")) return localNormal[thin] >= 0 ? 1 : -1;
|
|
13596
|
-
let axis = thin;
|
|
13597
|
-
for (let k = 0; k < 3; k++) if (Math.abs(localNormal[k]) > Math.abs(localNormal[axis])) axis = k;
|
|
13598
|
-
return faceCode(thin, axis, localNormal[axis]);
|
|
13599
|
-
};
|
|
13600
|
-
var onFace = (layer, face) => {
|
|
13601
|
-
const faces = layer.def.faces;
|
|
13602
|
-
if (faces === "all") return true;
|
|
13603
|
-
if (Math.abs(face) !== 1) return false;
|
|
13604
|
-
return faces === "both" || faces === (face > 0 ? "+" : "-");
|
|
13605
|
-
};
|
|
13606
|
-
var thinSidesOf = (def) => def.faces === "both" || def.faces === "all" ? [1, -1] : [def.faces === "+" ? 1 : -1];
|
|
13607
|
-
var isSpalled = (spalls, layer, face, point) => {
|
|
13608
|
-
for (const s of spalls ?? []) {
|
|
13609
|
-
if (s[0] !== layer || s[1] !== face) continue;
|
|
13610
|
-
const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
|
|
13611
|
-
if (dx * dx + dy * dy + dz * dz <= s[5] * s[5]) return true;
|
|
13612
|
-
}
|
|
13613
|
-
return false;
|
|
13614
|
-
};
|
|
13615
|
-
var outerLayer = (layers, spalls, face, point) => layers.find((l) => onFace(l, face) && !isSpalled(spalls, l.index, face, point));
|
|
13616
|
-
var layersEnergy = (layers, spalls, face, point) => {
|
|
13617
|
-
let sum = 0;
|
|
13618
|
-
for (const l of layers) if (onFace(l, face) && !isSpalled(spalls, l.index, face, point)) sum += l.energy;
|
|
13619
|
-
return sum;
|
|
13620
|
-
};
|
|
13621
|
-
var layersThickness = (layers, face) => {
|
|
13622
|
-
let sum = 0;
|
|
13623
|
-
for (const l of layers) if (onFace(l, face)) sum += l.def.thickness;
|
|
13624
|
-
return sum;
|
|
13625
|
-
};
|
|
13626
|
-
var tornPatchAt = (layers, spalls, face, point, radius) => {
|
|
13627
|
-
for (const l of layers) {
|
|
13628
|
-
if (!onFace(l, face)) continue;
|
|
13629
|
-
if (l.mat.fracture === "tear") {
|
|
13630
|
-
let best = -1;
|
|
13631
|
-
(spalls ?? []).forEach((s, i) => {
|
|
13632
|
-
if (s[0] !== l.index || s[1] !== face) return;
|
|
13633
|
-
const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
|
|
13634
|
-
const reach2 = s[5] + radius;
|
|
13635
|
-
if (dx * dx + dy * dy + dz * dz <= reach2 * reach2 && (best < 0 || s[5] > spalls[best][5])) best = i;
|
|
13636
|
-
});
|
|
13637
|
-
if (best >= 0) return { layer: l, spall: best };
|
|
13638
|
-
}
|
|
13639
|
-
if (!isSpalled(spalls, l.index, face, point)) return void 0;
|
|
13640
|
-
}
|
|
13641
|
-
return void 0;
|
|
13642
|
-
};
|
|
13643
13715
|
var REBAR_COVER = 0.03;
|
|
13644
13716
|
var COVER = REBAR_COVER;
|
|
13645
13717
|
var MAX_BARS_PER_DIRECTION = 24;
|
|
@@ -14753,6 +14825,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14753
14825
|
var materials_default = [
|
|
14754
14826
|
{
|
|
14755
14827
|
id: "steel",
|
|
14828
|
+
splitForm: "sheets",
|
|
14756
14829
|
density: 7850,
|
|
14757
14830
|
hpPerKg: 400,
|
|
14758
14831
|
penetration: 110,
|
|
@@ -14876,6 +14949,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14876
14949
|
},
|
|
14877
14950
|
{
|
|
14878
14951
|
id: "aluminium",
|
|
14952
|
+
splitForm: "sheets",
|
|
14879
14953
|
density: 2700,
|
|
14880
14954
|
hpPerKg: 250,
|
|
14881
14955
|
penetration: 60,
|
|
@@ -14915,6 +14989,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14915
14989
|
},
|
|
14916
14990
|
{
|
|
14917
14991
|
id: "copper",
|
|
14992
|
+
splitForm: "sheets",
|
|
14918
14993
|
density: 8960,
|
|
14919
14994
|
hpPerKg: 300,
|
|
14920
14995
|
penetration: 70,
|
|
@@ -15409,6 +15484,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15409
15484
|
},
|
|
15410
15485
|
{
|
|
15411
15486
|
id: "plastic",
|
|
15487
|
+
splitForm: "plates",
|
|
15412
15488
|
density: 1100,
|
|
15413
15489
|
hpPerKg: 60,
|
|
15414
15490
|
penetration: 8,
|
|
@@ -15443,6 +15519,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15443
15519
|
},
|
|
15444
15520
|
{
|
|
15445
15521
|
id: "rubber",
|
|
15522
|
+
splitForm: "strips",
|
|
15446
15523
|
density: 1100,
|
|
15447
15524
|
hpPerKg: 80,
|
|
15448
15525
|
penetration: 12,
|
|
@@ -15475,6 +15552,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15475
15552
|
},
|
|
15476
15553
|
{
|
|
15477
15554
|
id: "fabric",
|
|
15555
|
+
splitForm: "strips",
|
|
15478
15556
|
density: 400,
|
|
15479
15557
|
hpPerKg: 20,
|
|
15480
15558
|
penetration: 0.8,
|
|
@@ -15572,6 +15650,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15572
15650
|
},
|
|
15573
15651
|
{
|
|
15574
15652
|
id: "leather",
|
|
15653
|
+
splitForm: "strips",
|
|
15575
15654
|
density: 900,
|
|
15576
15655
|
hpPerKg: 50,
|
|
15577
15656
|
penetration: 4,
|
|
@@ -15608,6 +15687,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15608
15687
|
},
|
|
15609
15688
|
{
|
|
15610
15689
|
id: "paper",
|
|
15690
|
+
splitForm: "strips",
|
|
15611
15691
|
density: 700,
|
|
15612
15692
|
hpPerKg: 8,
|
|
15613
15693
|
penetration: 0.3,
|
|
@@ -16414,6 +16494,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16414
16494
|
var FOOT_BAND = 0.03;
|
|
16415
16495
|
var SEAM_STATIONS = 5;
|
|
16416
16496
|
var BEAM_PIECES = 4;
|
|
16497
|
+
var SAG_STATIONS = BEAM_PIECES + 1;
|
|
16417
16498
|
var SLENDER = 4;
|
|
16418
16499
|
var MAX_DOF = 1500;
|
|
16419
16500
|
var MECHANISM = 0.5;
|
|
@@ -16445,6 +16526,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16445
16526
|
const r = t / b;
|
|
16446
16527
|
return b * t ** 3 * (1 / 3 - 0.21 * r * (1 - r ** 4 / 12));
|
|
16447
16528
|
}
|
|
16529
|
+
var NO_PLACES = new Int32Array(0);
|
|
16448
16530
|
var AXES = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
16449
16531
|
function beamOf(part) {
|
|
16450
16532
|
const d = part.dims;
|
|
@@ -16615,37 +16697,142 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16615
16697
|
}
|
|
16616
16698
|
return out;
|
|
16617
16699
|
}
|
|
16618
|
-
function
|
|
16619
|
-
const
|
|
16620
|
-
for (
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16700
|
+
function sparseOf(count, pairs, last) {
|
|
16701
|
+
const joined = Array.from({ length: count }, () => /* @__PURE__ */ new Set());
|
|
16702
|
+
for (const [a, b] of pairs) {
|
|
16703
|
+
if (a === b) continue;
|
|
16704
|
+
joined[a].add(b);
|
|
16705
|
+
joined[b].add(a);
|
|
16706
|
+
}
|
|
16707
|
+
const order2 = new Int32Array(count).fill(-1);
|
|
16708
|
+
const held = [];
|
|
16709
|
+
for (let rank = 0; rank < count; rank++) {
|
|
16710
|
+
const feet = rank >= count - last.size;
|
|
16711
|
+
let least = -1;
|
|
16712
|
+
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;
|
|
16713
|
+
order2[least] = rank;
|
|
16714
|
+
const others = [...joined[least]];
|
|
16715
|
+
held.push(others);
|
|
16716
|
+
for (const a of others) {
|
|
16717
|
+
joined[a].delete(least);
|
|
16718
|
+
for (const b of others) if (a !== b) joined[a].add(b);
|
|
16719
|
+
}
|
|
16720
|
+
}
|
|
16721
|
+
const nodeStart = new Int32Array(count + 1);
|
|
16722
|
+
for (let rank = 0; rank < count; rank++) nodeStart[rank + 1] = nodeStart[rank] + held[rank].length;
|
|
16723
|
+
const below = new Int32Array(nodeStart[count]);
|
|
16724
|
+
const beforeStart = new Int32Array(count + 1);
|
|
16725
|
+
for (let rank = 0; rank < count; rank++) {
|
|
16726
|
+
const ranks = held[rank].map((node) => order2[node]).sort((p, q) => p - q);
|
|
16727
|
+
below.set(ranks, nodeStart[rank]);
|
|
16728
|
+
for (const other of ranks) beforeStart[other + 1] = beforeStart[other + 1] + 1;
|
|
16729
|
+
}
|
|
16730
|
+
for (let rank = 0; rank < count; rank++) beforeStart[rank + 1] = beforeStart[rank + 1] + beforeStart[rank];
|
|
16731
|
+
const before = new Int32Array(beforeStart[count]);
|
|
16732
|
+
const filled = beforeStart.slice(0, count);
|
|
16733
|
+
for (let rank = 0; rank < count; rank++) for (let t = nodeStart[rank]; t < nodeStart[rank + 1]; t++) before[filled[below[t]]++] = rank;
|
|
16734
|
+
const n = count * 6;
|
|
16735
|
+
const start = new Int32Array(n + 1);
|
|
16736
|
+
for (let j = 0; j < n; j++) {
|
|
16737
|
+
const rank = Math.floor(j / 6);
|
|
16738
|
+
start[j + 1] = start[j] + (5 - j % 6) + 6 * (nodeStart[rank + 1] - nodeStart[rank]);
|
|
16624
16739
|
}
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16628
|
-
|
|
16629
|
-
|
|
16630
|
-
|
|
16631
|
-
|
|
16632
|
-
|
|
16633
|
-
|
|
16634
|
-
|
|
16740
|
+
const rows = new Int32Array(start[n]);
|
|
16741
|
+
for (let j = 0; j < n; j++) {
|
|
16742
|
+
const rank = Math.floor(j / 6);
|
|
16743
|
+
let p = start[j];
|
|
16744
|
+
for (let i = j + 1; i < rank * 6 + 6; i++) rows[p++] = i;
|
|
16745
|
+
for (let t = nodeStart[rank]; t < nodeStart[rank + 1]; t++) for (let c = 0; c < 6; c++) rows[p++] = below[t] * 6 + c;
|
|
16746
|
+
}
|
|
16747
|
+
const head = (count - last.size) * 6;
|
|
16748
|
+
const tail = start.slice(0, n);
|
|
16749
|
+
for (let j = 0; j < head; j++) while (tail[j] < start[j + 1] && rows[tail[j]] < head) tail[j] = tail[j] + 1;
|
|
16750
|
+
return { order: order2, shape: { n, start, rows, nodeStart, below, beforeStart, before, size: n + rows.length, head, tail } };
|
|
16751
|
+
}
|
|
16752
|
+
function placeOf(shape, i, j) {
|
|
16753
|
+
if (i === j) return i;
|
|
16754
|
+
const rank = Math.floor(j / 6);
|
|
16755
|
+
const other = Math.floor(i / 6);
|
|
16756
|
+
const index = shape.n + shape.start[j];
|
|
16757
|
+
if (other === rank) return index + i - j - 1;
|
|
16758
|
+
let t = shape.nodeStart[rank];
|
|
16759
|
+
const end = shape.nodeStart[rank + 1];
|
|
16760
|
+
while (t < end && shape.below[t] !== other) t++;
|
|
16761
|
+
if (t === end) throw new Error(`assemblyFlex: (${i}, ${j}) is of two nodes the matrix was not made with as joined`);
|
|
16762
|
+
return index + 5 - j % 6 + 6 * (t - shape.nodeStart[rank]) + i % 6;
|
|
16763
|
+
}
|
|
16764
|
+
function addAt(shape, k, i, j, value) {
|
|
16765
|
+
if (j > i) return;
|
|
16766
|
+
const index = shape.placeOf(i, j);
|
|
16767
|
+
k[index] = k[index] + value;
|
|
16768
|
+
}
|
|
16769
|
+
function halfQuadratic(shape, k, x) {
|
|
16770
|
+
const { n, start, rows } = shape;
|
|
16771
|
+
let total = 0;
|
|
16772
|
+
for (let j = 0; j < n; j++) {
|
|
16773
|
+
const xj = x[j];
|
|
16774
|
+
if (xj === 0) continue;
|
|
16775
|
+
let column = 0.5 * k[j] * xj;
|
|
16776
|
+
for (let p = start[j]; p < start[j + 1]; p++) column += k[n + p] * x[rows[p]];
|
|
16777
|
+
total += xj * column;
|
|
16778
|
+
}
|
|
16779
|
+
return total;
|
|
16780
|
+
}
|
|
16781
|
+
function factor(shape, k, from, to) {
|
|
16782
|
+
const { n, start, rows, beforeStart, before } = shape;
|
|
16783
|
+
const next = from === 0 ? start.slice(0, n) : shape.tail.slice();
|
|
16784
|
+
const x = new Float64Array(n);
|
|
16785
|
+
const columns = new Int32Array(n);
|
|
16786
|
+
for (let i = from; i < to; i++) {
|
|
16787
|
+
const rank = Math.floor(i / 6);
|
|
16788
|
+
let count = 0;
|
|
16789
|
+
for (let t = beforeStart[rank]; t < beforeStart[rank + 1]; t++) for (let c = 0; c < 6; c++) columns[count++] = before[t] * 6 + c;
|
|
16790
|
+
for (let j = rank * 6; j < i; j++) columns[count++] = j;
|
|
16791
|
+
for (let c = 0; c < count; c++) {
|
|
16792
|
+
const j = columns[c];
|
|
16793
|
+
x[j] = k[n + next[j]];
|
|
16635
16794
|
}
|
|
16795
|
+
let diagonal = k[i];
|
|
16796
|
+
for (let c = 0; c < count; c++) {
|
|
16797
|
+
const j = columns[c];
|
|
16798
|
+
const value = x[j] / k[j];
|
|
16799
|
+
x[j] = 0;
|
|
16800
|
+
const end = next[j];
|
|
16801
|
+
for (let p = start[j]; p < end; p++) x[rows[p]] = x[rows[p]] - k[n + p] * value;
|
|
16802
|
+
diagonal -= value * value;
|
|
16803
|
+
k[n + end] = value;
|
|
16804
|
+
next[j] = end + 1;
|
|
16805
|
+
}
|
|
16806
|
+
if (!(diagonal > 0)) return false;
|
|
16807
|
+
k[i] = Math.sqrt(diagonal);
|
|
16636
16808
|
}
|
|
16637
|
-
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
|
|
16809
|
+
return true;
|
|
16810
|
+
}
|
|
16811
|
+
function substitute(shape, k, f) {
|
|
16812
|
+
const { n, start, rows } = shape;
|
|
16813
|
+
for (let j = 0; j < n; j++) {
|
|
16814
|
+
const value = f[j] / k[j];
|
|
16815
|
+
f[j] = value;
|
|
16816
|
+
for (let p = start[j]; p < start[j + 1]; p++) f[rows[p]] = f[rows[p]] - k[n + p] * value;
|
|
16641
16817
|
}
|
|
16642
|
-
for (let
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
|
|
16818
|
+
for (let j = n - 1; j >= 0; j--) {
|
|
16819
|
+
let sum = f[j];
|
|
16820
|
+
for (let p = start[j]; p < start[j + 1]; p++) sum -= k[n + p] * f[rows[p]];
|
|
16821
|
+
f[j] = sum / k[j];
|
|
16646
16822
|
}
|
|
16647
|
-
return true;
|
|
16648
16823
|
}
|
|
16824
|
+
var sparseLinear = (count, pairs, last) => {
|
|
16825
|
+
const { order: order2, shape } = sparseOf(count, pairs, last);
|
|
16826
|
+
return {
|
|
16827
|
+
order: order2,
|
|
16828
|
+
size: shape.size,
|
|
16829
|
+
head: shape.head,
|
|
16830
|
+
placeOf: (i, j) => placeOf(shape, i, j),
|
|
16831
|
+
factor: (k, from, to) => factor(shape, k, from, to),
|
|
16832
|
+
substitute: (k, f) => substitute(shape, k, f),
|
|
16833
|
+
halfQuadratic: (k, x) => halfQuadratic(shape, k, x)
|
|
16834
|
+
};
|
|
16835
|
+
};
|
|
16649
16836
|
function hullOf(points) {
|
|
16650
16837
|
const sorted = [...points].sort((p, q) => p[0] - q[0] || p[1] - q[1]);
|
|
16651
16838
|
const turn = (o, p, q) => (p[0] - o[0]) * (q[1] - o[1]) - (p[1] - o[1]) * (q[0] - o[0]);
|
|
@@ -16723,20 +16910,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16723
16910
|
beam.nodes = kept.map((s) => nodes.push({ at: vec.madd(beam.part.position, beam.axis, s) }) - 1);
|
|
16724
16911
|
}
|
|
16725
16912
|
if (nodes.length * 6 > MAX_DOF) return null;
|
|
16726
|
-
const lo = [Infinity, Infinity, Infinity];
|
|
16727
|
-
const hi = [-Infinity, -Infinity, -Infinity];
|
|
16728
|
-
for (const node of nodes) for (let k = 0; k < 3; k++) {
|
|
16729
|
-
lo[k] = Math.min(lo[k], node.at[k]);
|
|
16730
|
-
hi[k] = Math.max(hi[k], node.at[k]);
|
|
16731
|
-
}
|
|
16732
|
-
let main = 0;
|
|
16733
|
-
if (hi[1] - lo[1] > hi[main] - lo[main]) main = 1;
|
|
16734
|
-
if (hi[2] - lo[2] > hi[main] - lo[main]) main = 2;
|
|
16735
|
-
const ranked = nodes.map((_, i) => i).sort((p, q) => nodes[p].at[main] - nodes[q].at[main] || p - q);
|
|
16736
16913
|
const order2 = new Int32Array(nodes.length);
|
|
16737
|
-
|
|
16738
|
-
order2[node] = rank;
|
|
16739
|
-
});
|
|
16914
|
+
for (let i = 0; i < nodes.length; i++) order2[i] = i;
|
|
16740
16915
|
const dofsOf = (node) => [0, 1, 2, 3, 4, 5].map((i) => order2[node] * 6 + i);
|
|
16741
16916
|
const nearest = (beam, p) => {
|
|
16742
16917
|
const t = along2(beam, p);
|
|
@@ -16744,7 +16919,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16744
16919
|
for (let i = 1; i < beam.stations.length; i++) if (Math.abs(beam.stations[i] - t) < Math.abs(beam.stations[best] - t)) best = i;
|
|
16745
16920
|
return beam.nodes[best];
|
|
16746
16921
|
};
|
|
16747
|
-
const
|
|
16922
|
+
const made = [];
|
|
16748
16923
|
for (const beam of beams.values()) {
|
|
16749
16924
|
const section = sectionOf(beam);
|
|
16750
16925
|
if (!section) {
|
|
@@ -16755,7 +16930,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16755
16930
|
for (let i = 0; i + 1 < beam.nodes.length; i++) {
|
|
16756
16931
|
const length = beam.stations[i + 1] - beam.stations[i];
|
|
16757
16932
|
const k = toObjectFrame(beamLocal(section, length), 12, beam.axis, beam.u, beam.v);
|
|
16758
|
-
|
|
16933
|
+
made.push({ dofs: [...dofsOf(beam.nodes[i]), ...dofsOf(beam.nodes[i + 1])], k, parts: [beam.part.id], places: NO_PLACES });
|
|
16759
16934
|
}
|
|
16760
16935
|
}
|
|
16761
16936
|
for (const [joint, stations] of stationed) {
|
|
@@ -16784,7 +16959,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16784
16959
|
for (let p = 0; p < 12; p++) for (let q = 0; q < 12; q++) k[p * 12 + q] = k[p * 12 + q] + stiffness * b12[p] * b12[q];
|
|
16785
16960
|
}
|
|
16786
16961
|
}
|
|
16787
|
-
|
|
16962
|
+
made.push({ dofs: [...dofsOf(na), ...dofsOf(nb)], k, parts: [joint.a, joint.b], places: NO_PLACES });
|
|
16788
16963
|
}
|
|
16789
16964
|
}
|
|
16790
16965
|
const supports = [];
|
|
@@ -16795,7 +16970,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16795
16970
|
supports.push({ part: id, node, arm: vec.sub(at2, nodes[node].at), at: at2 });
|
|
16796
16971
|
}
|
|
16797
16972
|
}
|
|
16798
|
-
const
|
|
16973
|
+
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)));
|
|
16974
|
+
order2.set(shape.order);
|
|
16975
|
+
const elements = made.map((element) => {
|
|
16976
|
+
const dofs = element.dofs.map((dof) => order2[Math.floor(dof / 6)] * 6 + dof % 6);
|
|
16977
|
+
const places = new Int32Array(dofs.length * dofs.length);
|
|
16978
|
+
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]);
|
|
16979
|
+
return { ...element, dofs, places };
|
|
16980
|
+
});
|
|
16981
|
+
const frame2 = { nodes, beams, elements, supports, order: order2, shape };
|
|
16799
16982
|
const before = lost.size > 0 ? solveFrame(frame2, input, joints, structural, /* @__PURE__ */ new Set(), g, null) : null;
|
|
16800
16983
|
const after = solveFrame(frame2, input, joints, structural, lost, g, before);
|
|
16801
16984
|
if (!after) return null;
|
|
@@ -16835,12 +17018,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16835
17018
|
const delta = new Float64Array(n);
|
|
16836
17019
|
for (let i = 0; i < n; i++) delta[i] = after.u[i] - before.u[i];
|
|
16837
17020
|
for (const beam of beams.values()) if (!after.standing.has(beam.part.id)) for (const node of beam.nodes) for (const dof of dofsOf(node)) delta[dof] = 0;
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
let
|
|
16841
|
-
|
|
16842
|
-
|
|
16843
|
-
|
|
17021
|
+
const potential = (x) => {
|
|
17022
|
+
let height = 0;
|
|
17023
|
+
for (let i = 0; i < n; i++) height += after.load[i] * x[i];
|
|
17024
|
+
return frame2.shape.halfQuadratic(after.structure, x) - height;
|
|
17025
|
+
};
|
|
17026
|
+
const had = new Float64Array(n);
|
|
17027
|
+
for (let i = 0; i < n; i++) had[i] = after.u[i] - delta[i];
|
|
17028
|
+
released = Math.max(0, potential(had) - potential(after.u));
|
|
16844
17029
|
spin = spinOf({ frame: frame2, after, delta, released, centre: allCentre, mass: all, floor, g });
|
|
16845
17030
|
}
|
|
16846
17031
|
return {
|
|
@@ -16855,6 +17040,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16855
17040
|
if (!beam || !after.standing.has(id)) return null;
|
|
16856
17041
|
const node = nearest(beam, point);
|
|
16857
17042
|
return moved(after, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 });
|
|
17043
|
+
},
|
|
17044
|
+
settlement(id) {
|
|
17045
|
+
const beam = beams.get(id);
|
|
17046
|
+
if (!beam) return null;
|
|
17047
|
+
const carrier = after.standing.has(id) ? null : after.masses.find((p) => p.part === id);
|
|
17048
|
+
if (!after.standing.has(id) && !carrier) return null;
|
|
17049
|
+
const from = vec.madd(beam.part.position, beam.axis, -beam.length / 2);
|
|
17050
|
+
const to = vec.madd(beam.part.position, beam.axis, beam.length / 2);
|
|
17051
|
+
const drop = [];
|
|
17052
|
+
for (let i = 0; i < SAG_STATIONS; i++) {
|
|
17053
|
+
const point = vec.madd(from, beam.axis, beam.length * i / (SAG_STATIONS - 1));
|
|
17054
|
+
const node = carrier ? carrier.node : nearest(beam, point);
|
|
17055
|
+
drop.push(-moved(after, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 })[1]);
|
|
17056
|
+
}
|
|
17057
|
+
return { from, to, drop };
|
|
16858
17058
|
}
|
|
16859
17059
|
};
|
|
16860
17060
|
}
|
|
@@ -16879,7 +17079,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16879
17079
|
return standing;
|
|
16880
17080
|
}
|
|
16881
17081
|
function solveFrame(frame2, input, joints, structural, gone, g, from) {
|
|
16882
|
-
const { nodes, beams, order: order2 } = frame2;
|
|
17082
|
+
const { nodes, beams, order: order2, shape } = frame2;
|
|
16883
17083
|
const n = nodes.length * 6;
|
|
16884
17084
|
const standing = standingParts(frame2, joints, structural, gone);
|
|
16885
17085
|
if (standing.size === 0) return null;
|
|
@@ -16939,50 +17139,50 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16939
17139
|
f[base2 + 3] = f[base2 + 3] - p.arm[2] * weight;
|
|
16940
17140
|
f[base2 + 5] = f[base2 + 5] + p.arm[0] * weight;
|
|
16941
17141
|
}
|
|
16942
|
-
const structure = new Float64Array(
|
|
17142
|
+
const structure = new Float64Array(shape.size);
|
|
16943
17143
|
let largest = 0;
|
|
16944
17144
|
for (const element of frame2.elements) {
|
|
16945
17145
|
if (!element.parts.every((id) => standing.has(id))) continue;
|
|
16946
|
-
const
|
|
16947
|
-
for (let
|
|
16948
|
-
for (let q = 0; q < size; q++) structure[element.dofs[p] * n + element.dofs[q]] = structure[element.dofs[p] * n + element.dofs[q]] + element.k[p * size + q];
|
|
16949
|
-
}
|
|
17146
|
+
const { places, k: k2 } = element;
|
|
17147
|
+
for (let t = 0; t < places.length; t++) if (places[t] >= 0) structure[places[t]] = structure[places[t]] + k2[t];
|
|
16950
17148
|
}
|
|
16951
|
-
for (let i = 0; i < n; i++) largest = Math.max(largest, structure[i
|
|
17149
|
+
for (let i = 0; i < n; i++) largest = Math.max(largest, structure[i]);
|
|
16952
17150
|
if (largest <= 0) return null;
|
|
16953
17151
|
const free = new Uint8Array(n);
|
|
16954
17152
|
for (const id of standing) for (const node of beams.get(id).nodes) for (let i = 0; i < 6; i++) free[order2[node] * 6 + i] = 1;
|
|
16955
17153
|
for (let i = 0; i < n; i++) {
|
|
16956
17154
|
if (!free[i]) {
|
|
16957
|
-
structure[i
|
|
17155
|
+
structure[i] = largest;
|
|
16958
17156
|
f[i] = 0;
|
|
16959
|
-
} else structure
|
|
17157
|
+
} else addAt(shape, structure, i, i, largest * SOFT);
|
|
16960
17158
|
}
|
|
16961
17159
|
const feet = frame2.supports.filter((s) => standing.has(s.part));
|
|
16962
17160
|
const holds2 = feet.map((s) => !from || from.holding.includes(s));
|
|
16963
17161
|
const footed = [...new Set(feet.map((s) => s.part))];
|
|
16964
17162
|
const grips = new Map(footed.map((id) => [id, true]));
|
|
16965
17163
|
const friction = input.friction ?? FOOT_FRICTION;
|
|
16966
|
-
const
|
|
17164
|
+
const factored = structure.slice();
|
|
17165
|
+
if (!shape.factor(factored, 0, shape.head)) return null;
|
|
17166
|
+
const k = new Float64Array(shape.size);
|
|
16967
17167
|
const u = new Float64Array(n);
|
|
16968
|
-
const build = () => {
|
|
16969
|
-
k.set(
|
|
17168
|
+
const build = (from2) => {
|
|
17169
|
+
k.set(from2);
|
|
16970
17170
|
const held = /* @__PURE__ */ new Map();
|
|
16971
17171
|
feet.forEach((s, index) => {
|
|
16972
17172
|
if (!holds2[index]) return;
|
|
16973
17173
|
const row = armRows(s.arm)[1];
|
|
16974
17174
|
const base2 = order2[s.node] * 6;
|
|
16975
|
-
for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++)
|
|
17175
|
+
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]);
|
|
16976
17176
|
held.set(s.part, [...held.get(s.part) ?? [], s]);
|
|
16977
17177
|
});
|
|
16978
17178
|
for (const [id, points] of held) {
|
|
16979
17179
|
const { node, arm } = gripOf(points);
|
|
16980
17180
|
const upright = order2[node] * 6 + 4;
|
|
16981
|
-
k
|
|
17181
|
+
addAt(shape, k, upright, upright, RIGID_TURN);
|
|
16982
17182
|
if (!grips.get(id)) continue;
|
|
16983
17183
|
const rows = armRows(arm);
|
|
16984
17184
|
const base2 = order2[node] * 6;
|
|
16985
|
-
for (const row of [rows[0], rows[2]]) for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++)
|
|
17185
|
+
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]);
|
|
16986
17186
|
}
|
|
16987
17187
|
};
|
|
16988
17188
|
const liftOf = (s) => {
|
|
@@ -16991,9 +17191,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16991
17191
|
};
|
|
16992
17192
|
const rounds = 4 * feet.length + 2 * footed.length + 4;
|
|
16993
17193
|
for (let round3 = 0; round3 < rounds; round3++) {
|
|
16994
|
-
build();
|
|
17194
|
+
build(factored);
|
|
16995
17195
|
u.set(f);
|
|
16996
|
-
if (!
|
|
17196
|
+
if (!shape.factor(k, shape.head, n)) return null;
|
|
17197
|
+
shape.substitute(k, u);
|
|
16997
17198
|
const pull = 1e-12;
|
|
16998
17199
|
const sink = -1e-9;
|
|
16999
17200
|
if (round3 === 0) {
|
|
@@ -17047,8 +17248,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17047
17248
|
if (worst > MECHANISM) return null;
|
|
17048
17249
|
const holding = feet.filter((_, index) => holds2[index]);
|
|
17049
17250
|
if (holding.length < 3) return null;
|
|
17050
|
-
|
|
17051
|
-
return { u: u.slice(), k: k.slice(), holding, masses, standing };
|
|
17251
|
+
return { u: u.slice(), structure, load: f, holding, masses, standing };
|
|
17052
17252
|
}
|
|
17053
17253
|
return null;
|
|
17054
17254
|
}
|
|
@@ -17277,7 +17477,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17277
17477
|
var TEAR_JOULES = 150;
|
|
17278
17478
|
var STRIP_THICKNESS = 15e-4;
|
|
17279
17479
|
var UNIT_FRAGMENT_FACTOR = 4;
|
|
17280
|
-
var BREACH_GRID_CAP = 4096;
|
|
17281
17480
|
var MASONRY_CRUMBLE_SPEED = 0.6;
|
|
17282
17481
|
var MASONRY_TOPPLE = 0.4;
|
|
17283
17482
|
var MASONRY_TOPPLE_MIN_HEIGHT = 0.5;
|
|
@@ -17494,6 +17693,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17494
17693
|
objectsRevision++;
|
|
17495
17694
|
}
|
|
17496
17695
|
};
|
|
17696
|
+
const movedObjects = [];
|
|
17697
|
+
const markMoved = (o) => {
|
|
17698
|
+
if (o.rayMoved) return;
|
|
17699
|
+
o.rayMoved = true;
|
|
17700
|
+
movedObjects.push(o);
|
|
17701
|
+
};
|
|
17497
17702
|
const listeners = /* @__PURE__ */ new Map();
|
|
17498
17703
|
let cur = [];
|
|
17499
17704
|
const blasts = [];
|
|
@@ -17502,6 +17707,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17502
17707
|
const primed = /* @__PURE__ */ new Map();
|
|
17503
17708
|
let orderCounter = 0;
|
|
17504
17709
|
const impls = /* @__PURE__ */ new Map();
|
|
17710
|
+
let implsRevision = 0;
|
|
17505
17711
|
const taken = (id) => objects.has(id) || impls.has(id);
|
|
17506
17712
|
const emit = (e) => {
|
|
17507
17713
|
cur.push(e);
|
|
@@ -17668,6 +17874,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17668
17874
|
unsup: [],
|
|
17669
17875
|
anyAnchor: false,
|
|
17670
17876
|
order: ++orderCounter,
|
|
17877
|
+
rayStamp: 0,
|
|
17878
|
+
raySlot: 0,
|
|
17879
|
+
rayMoved: false,
|
|
17671
17880
|
loose: carry?.loose ?? false,
|
|
17672
17881
|
cast: /* @__PURE__ */ new Map(),
|
|
17673
17882
|
base: { pos: [pos[0], pos[1], pos[2]], rot: [rot[0], rot[1], rot[2], rot[3]] }
|
|
@@ -18502,6 +18711,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18502
18711
|
applySoilPose(o);
|
|
18503
18712
|
};
|
|
18504
18713
|
const applySoilPose = (o) => {
|
|
18714
|
+
markMoved(o);
|
|
18505
18715
|
const so = o.soil;
|
|
18506
18716
|
if (!so) {
|
|
18507
18717
|
o.st.position = [o.base.pos[0], o.base.pos[1], o.base.pos[2]];
|
|
@@ -19277,6 +19487,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19277
19487
|
return turn;
|
|
19278
19488
|
};
|
|
19279
19489
|
const copyOf = (v) => [v[0], v[1], v[2]];
|
|
19490
|
+
let bestInto = null;
|
|
19491
|
+
const rayPoint = [0, 0, 0];
|
|
19492
|
+
const keepBest = (into, object2, part, point, normal, distance2, pathLen) => {
|
|
19493
|
+
if (!into) return { object: object2, part, point: copyOf(point), normal: copyOf(normal), distance: distance2, pathLen };
|
|
19494
|
+
into.object = object2;
|
|
19495
|
+
into.part = part;
|
|
19496
|
+
into.point[0] = point[0];
|
|
19497
|
+
into.point[1] = point[1];
|
|
19498
|
+
into.point[2] = point[2];
|
|
19499
|
+
into.normal[0] = normal[0];
|
|
19500
|
+
into.normal[1] = normal[1];
|
|
19501
|
+
into.normal[2] = normal[2];
|
|
19502
|
+
into.distance = distance2;
|
|
19503
|
+
into.pathLen = pathLen;
|
|
19504
|
+
return into;
|
|
19505
|
+
};
|
|
19506
|
+
const bestScratch = { object: "", part: "", point: [0, 0, 0], normal: [0, 0, 0], distance: 0, pathLen: 0 };
|
|
19507
|
+
const isTerrainPart = (objectId, partId) => {
|
|
19508
|
+
const parts2 = objects.get(objectId)?.parts;
|
|
19509
|
+
if (!parts2) return false;
|
|
19510
|
+
for (const p of parts2) if (p.spec.id === partId) return p.spec.tags?.includes("terrain") === true;
|
|
19511
|
+
return false;
|
|
19512
|
+
};
|
|
19280
19513
|
const objectTurnBack = [0, 0, 0, 1];
|
|
19281
19514
|
const objectOrigin = [0, 0, 0];
|
|
19282
19515
|
const objectDirection = [0, 0, 0];
|
|
@@ -19397,11 +19630,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19397
19630
|
return grid;
|
|
19398
19631
|
};
|
|
19399
19632
|
const partsAlong = (o, lo, ld, maxDist) => {
|
|
19400
|
-
if (o.parts.length < PART_GRID_MIN_PARTS || !lo.
|
|
19401
|
-
partGridOf(o).candidates(lo, ld, maxDist, gridCandidates);
|
|
19402
|
-
|
|
19403
|
-
|
|
19404
|
-
|
|
19633
|
+
if (o.parts.length < PART_GRID_MIN_PARTS || !(Number.isFinite(lo[0]) && Number.isFinite(lo[1]) && Number.isFinite(lo[2]) && Number.isFinite(ld[0]) && Number.isFinite(ld[1]) && Number.isFinite(ld[2]))) return -1;
|
|
19634
|
+
const count = partGridOf(o).candidates(lo, ld, maxDist, gridCandidates);
|
|
19635
|
+
for (let i = 0; i < count; i++) {
|
|
19636
|
+
const p = o.parts[gridCandidates[i]];
|
|
19637
|
+
if (i < gridParts.length) gridParts[i] = p;
|
|
19638
|
+
else gridParts.push(p);
|
|
19639
|
+
}
|
|
19640
|
+
return count;
|
|
19405
19641
|
};
|
|
19406
19642
|
const splitInto = (o, cuts) => {
|
|
19407
19643
|
const carryFor = (keep, keepOpen = () => false) => ({
|
|
@@ -19439,6 +19675,162 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19439
19675
|
let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
|
|
19440
19676
|
const metObjects = [];
|
|
19441
19677
|
const rayObjects = [];
|
|
19678
|
+
let objectList = [];
|
|
19679
|
+
let objectListFor = -1;
|
|
19680
|
+
const objectsInOrder = () => {
|
|
19681
|
+
if (objectListFor !== objectsRevision) {
|
|
19682
|
+
objectList = [...objects.values()];
|
|
19683
|
+
objectListFor = objectsRevision;
|
|
19684
|
+
}
|
|
19685
|
+
return objectList;
|
|
19686
|
+
};
|
|
19687
|
+
let implList = [];
|
|
19688
|
+
let implListFor = -1;
|
|
19689
|
+
const implsInOrder = () => {
|
|
19690
|
+
if (implListFor !== implsRevision) {
|
|
19691
|
+
implList = [...impls.values()];
|
|
19692
|
+
implListFor = implsRevision;
|
|
19693
|
+
}
|
|
19694
|
+
return implList;
|
|
19695
|
+
};
|
|
19696
|
+
const NO_IMPLS = [];
|
|
19697
|
+
const RAY_CELL = 2;
|
|
19698
|
+
const RAY_GRID_BIG = 4;
|
|
19699
|
+
const RAY_GRID_HALF = 512;
|
|
19700
|
+
const RAY_GRID_MAX_CELLS = 64;
|
|
19701
|
+
const gridCells = /* @__PURE__ */ new Map();
|
|
19702
|
+
const gridCentre = [0, 0, 0];
|
|
19703
|
+
const gridSpans = /* @__PURE__ */ new WeakMap();
|
|
19704
|
+
const bigObjects = [];
|
|
19705
|
+
let gridFor = -1;
|
|
19706
|
+
let gridQuery = 0;
|
|
19707
|
+
const gridHits = [];
|
|
19708
|
+
const cellOf = (v) => Math.floor(v / RAY_CELL) | 0;
|
|
19709
|
+
const inGrid = (c) => c >= -RAY_GRID_HALF && c < RAY_GRID_HALF;
|
|
19710
|
+
const cellKey2 = (ix, iy, iz) => ix + RAY_GRID_HALF + (iy + RAY_GRID_HALF) * 1024 + (iz + RAY_GRID_HALF) * 1048576 | 0;
|
|
19711
|
+
const cellAt = (key2) => {
|
|
19712
|
+
let cell = gridCells.get(key2);
|
|
19713
|
+
if (!cell) {
|
|
19714
|
+
cell = [];
|
|
19715
|
+
gridCells.set(key2, cell);
|
|
19716
|
+
}
|
|
19717
|
+
return cell;
|
|
19718
|
+
};
|
|
19719
|
+
const dropFrom = (list2, o) => {
|
|
19720
|
+
const at2 = list2.indexOf(o);
|
|
19721
|
+
if (at2 < 0) return;
|
|
19722
|
+
list2[at2] = list2[list2.length - 1];
|
|
19723
|
+
list2.length--;
|
|
19724
|
+
};
|
|
19725
|
+
const unplace = (o, span) => {
|
|
19726
|
+
if (!span.placed) return;
|
|
19727
|
+
span.placed = false;
|
|
19728
|
+
if (span.big) {
|
|
19729
|
+
dropFrom(bigObjects, o);
|
|
19730
|
+
return;
|
|
19731
|
+
}
|
|
19732
|
+
for (let iz = span.z0; iz <= span.z1; iz++) for (let iy = span.y0; iy <= span.y1; iy++) for (let ix = span.x0; ix <= span.x1; ix++) dropFrom(cellAt(cellKey2(ix, iy, iz)), o);
|
|
19733
|
+
};
|
|
19734
|
+
const place = (o) => {
|
|
19735
|
+
o.raySlot = slots.get(o.id) ?? 0;
|
|
19736
|
+
let span = gridSpans.get(o);
|
|
19737
|
+
const c = rotateVecInto(o.st.rotation, o.bc, gridCentre);
|
|
19738
|
+
c[0] += o.st.position[0];
|
|
19739
|
+
c[1] += o.st.position[1];
|
|
19740
|
+
c[2] += o.st.position[2];
|
|
19741
|
+
const r = o.br;
|
|
19742
|
+
const x0 = cellOf(c[0] - r), y0 = cellOf(c[1] - r), z0 = cellOf(c[2] - r);
|
|
19743
|
+
const x1 = cellOf(c[0] + r), y1 = cellOf(c[1] + r), z1 = cellOf(c[2] + r);
|
|
19744
|
+
const big = !(x1 - x0 < RAY_GRID_BIG && y1 - y0 < RAY_GRID_BIG && z1 - z0 < RAY_GRID_BIG) || !(inGrid(x0) && inGrid(y0) && inGrid(z0) && inGrid(x1) && inGrid(y1) && inGrid(z1));
|
|
19745
|
+
if (span?.placed && span.big === big && (big || span.x0 === x0 && span.y0 === y0 && span.z0 === z0 && span.x1 === x1 && span.y1 === y1 && span.z1 === z1)) return;
|
|
19746
|
+
if (span) unplace(o, span);
|
|
19747
|
+
else {
|
|
19748
|
+
span = { x0, y0, z0, x1, y1, z1, big, placed: false };
|
|
19749
|
+
gridSpans.set(o, span);
|
|
19750
|
+
}
|
|
19751
|
+
span.x0 = x0;
|
|
19752
|
+
span.y0 = y0;
|
|
19753
|
+
span.z0 = z0;
|
|
19754
|
+
span.x1 = x1;
|
|
19755
|
+
span.y1 = y1;
|
|
19756
|
+
span.z1 = z1;
|
|
19757
|
+
span.big = big;
|
|
19758
|
+
span.placed = true;
|
|
19759
|
+
if (big) {
|
|
19760
|
+
bigObjects.push(o);
|
|
19761
|
+
return;
|
|
19762
|
+
}
|
|
19763
|
+
for (let iz = z0; iz <= z1; iz++) for (let iy = y0; iy <= y1; iy++) for (let ix = x0; ix <= x1; ix++) cellAt(cellKey2(ix, iy, iz)).push(o);
|
|
19764
|
+
};
|
|
19765
|
+
const refreshGrid = () => {
|
|
19766
|
+
if (gridFor !== objectsRevision) {
|
|
19767
|
+
for (const cell of gridCells.values()) cell.length = 0;
|
|
19768
|
+
bigObjects.length = 0;
|
|
19769
|
+
const all = objectsInOrder();
|
|
19770
|
+
for (let i = 0; i < all.length; i++) {
|
|
19771
|
+
const span = gridSpans.get(all[i]);
|
|
19772
|
+
if (span) span.placed = false;
|
|
19773
|
+
place(all[i]);
|
|
19774
|
+
}
|
|
19775
|
+
for (let i = 0; i < movedObjects.length; i++) movedObjects[i].rayMoved = false;
|
|
19776
|
+
movedObjects.length = 0;
|
|
19777
|
+
gridFor = objectsRevision;
|
|
19778
|
+
return;
|
|
19779
|
+
}
|
|
19780
|
+
for (let i = 0; i < movedObjects.length; i++) {
|
|
19781
|
+
const o = movedObjects[i];
|
|
19782
|
+
o.rayMoved = false;
|
|
19783
|
+
if (objects.get(o.id) === o) place(o);
|
|
19784
|
+
}
|
|
19785
|
+
movedObjects.length = 0;
|
|
19786
|
+
};
|
|
19787
|
+
const sortBySlot = (list2, count) => {
|
|
19788
|
+
for (let i = 1; i < count; i++) {
|
|
19789
|
+
const o = list2[i];
|
|
19790
|
+
let j = i - 1;
|
|
19791
|
+
while (j >= 0 && list2[j].raySlot > o.raySlot) {
|
|
19792
|
+
list2[j + 1] = list2[j];
|
|
19793
|
+
j--;
|
|
19794
|
+
}
|
|
19795
|
+
list2[j + 1] = o;
|
|
19796
|
+
}
|
|
19797
|
+
};
|
|
19798
|
+
const objectsNear = (origin, d, maxDist) => {
|
|
19799
|
+
if (!(maxDist < Infinity)) return -1;
|
|
19800
|
+
const ex = origin[0] + d[0] * maxDist, ey = origin[1] + d[1] * maxDist, ez = origin[2] + d[2] * maxDist;
|
|
19801
|
+
const x0 = cellOf(Math.min(origin[0], ex)), y0 = cellOf(Math.min(origin[1], ey)), z0 = cellOf(Math.min(origin[2], ez));
|
|
19802
|
+
const x1 = cellOf(Math.max(origin[0], ex)), y1 = cellOf(Math.max(origin[1], ey)), z1 = cellOf(Math.max(origin[2], ez));
|
|
19803
|
+
if (!(inGrid(x0) && inGrid(y0) && inGrid(z0) && inGrid(x1) && inGrid(y1) && inGrid(z1))) return -1;
|
|
19804
|
+
if ((x1 - x0 + 1) * (y1 - y0 + 1) * (z1 - z0 + 1) > RAY_GRID_MAX_CELLS) return -1;
|
|
19805
|
+
refreshGrid();
|
|
19806
|
+
const stamp = ++gridQuery;
|
|
19807
|
+
let count = 0;
|
|
19808
|
+
for (let i = 0; i < bigObjects.length; i++) {
|
|
19809
|
+
bigObjects[i].rayStamp = stamp;
|
|
19810
|
+
if (count < gridHits.length) gridHits[count] = bigObjects[i];
|
|
19811
|
+
else gridHits.push(bigObjects[i]);
|
|
19812
|
+
count++;
|
|
19813
|
+
}
|
|
19814
|
+
for (let iz = z0; iz <= z1; iz++)
|
|
19815
|
+
for (let iy = y0; iy <= y1; iy++)
|
|
19816
|
+
for (let ix = x0; ix <= x1; ix++) {
|
|
19817
|
+
const cell = gridCells.get(cellKey2(ix, iy, iz));
|
|
19818
|
+
if (!cell) continue;
|
|
19819
|
+
for (let i = 0; i < cell.length; i++) {
|
|
19820
|
+
const o = cell[i];
|
|
19821
|
+
if (o.rayStamp === stamp) continue;
|
|
19822
|
+
o.rayStamp = stamp;
|
|
19823
|
+
if (count < gridHits.length) gridHits[count] = o;
|
|
19824
|
+
else gridHits.push(o);
|
|
19825
|
+
count++;
|
|
19826
|
+
}
|
|
19827
|
+
}
|
|
19828
|
+
sortBySlot(gridHits, count);
|
|
19829
|
+
return count;
|
|
19830
|
+
};
|
|
19831
|
+
const NO_SKIP = {};
|
|
19832
|
+
const rayDirections = [];
|
|
19833
|
+
let rayDepth = 0;
|
|
19442
19834
|
const candidatesOf2 = (hook) => {
|
|
19443
19835
|
const asked = hook.candidates;
|
|
19444
19836
|
if (!asked) return null;
|
|
@@ -19464,15 +19856,39 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19464
19856
|
}
|
|
19465
19857
|
return rayObjects;
|
|
19466
19858
|
};
|
|
19467
|
-
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip =
|
|
19468
|
-
const
|
|
19859
|
+
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = NO_SKIP, scope, drawn = false, passed) => {
|
|
19860
|
+
const into = bestInto;
|
|
19861
|
+
bestInto = null;
|
|
19862
|
+
const d = rayDirections[rayDepth] ?? (rayDirections[rayDepth] = [0, 0, 0]);
|
|
19863
|
+
const length = Math.sqrt(dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2]);
|
|
19864
|
+
if (length < 1e-9) {
|
|
19865
|
+
d[0] = 0;
|
|
19866
|
+
d[1] = 1;
|
|
19867
|
+
d[2] = 0;
|
|
19868
|
+
} else {
|
|
19869
|
+
d[0] = dir[0] / length;
|
|
19870
|
+
d[1] = dir[1] / length;
|
|
19871
|
+
d[2] = dir[2] / length;
|
|
19872
|
+
}
|
|
19873
|
+
rayDepth++;
|
|
19874
|
+
try {
|
|
19875
|
+
return rayFrom(origin, d, maxDist, into, ignore, worldOnly, precise, skip, scope, drawn, passed);
|
|
19876
|
+
} finally {
|
|
19877
|
+
rayDepth--;
|
|
19878
|
+
}
|
|
19879
|
+
};
|
|
19880
|
+
const rayFrom = (origin, d, maxDist, into, ignore, worldOnly, precise, skip, scope, drawn, passed) => {
|
|
19469
19881
|
const asked = rayBroad && !scope && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
|
|
19470
19882
|
const candidates = asked ? candidatesOf2(asked) : null;
|
|
19471
19883
|
const outside = candidates ? null : asked;
|
|
19472
19884
|
const minRadius = skip.minObjectRadius ?? 0;
|
|
19473
19885
|
let best = null;
|
|
19474
19886
|
const counts = sweepCounts;
|
|
19475
|
-
|
|
19887
|
+
const near = scope || candidates ? -1 : objectsNear(origin, d, maxDist);
|
|
19888
|
+
const visited = scope ? scope.objects : candidates ?? (near >= 0 ? gridHits : objectsInOrder());
|
|
19889
|
+
const visitedCount = near >= 0 ? near : visited.length;
|
|
19890
|
+
for (let oi = 0; oi < visitedCount; oi++) {
|
|
19891
|
+
const o = visited[oi];
|
|
19476
19892
|
if (counts) counts.objectVisits++;
|
|
19477
19893
|
if (skip.skipLoose && o.loose || o.br < minRadius) continue;
|
|
19478
19894
|
if (outside && !outside.mayMeet(o.id)) continue;
|
|
@@ -19487,7 +19903,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19487
19903
|
objectOrigin[2] = origin[2] - o.st.position[2];
|
|
19488
19904
|
const lo = rotateVecInto(objectTurnBack, objectOrigin, objectOrigin);
|
|
19489
19905
|
const ld = rotateVecInto(objectTurnBack, d, objectDirection);
|
|
19490
|
-
|
|
19906
|
+
const scoped = scope?.parts.get(o);
|
|
19907
|
+
const gathered = scoped || counts ? -1 : partsAlong(o, lo, ld, maxDist);
|
|
19908
|
+
const along2 = scoped ?? (gathered >= 0 ? gridParts : o.parts);
|
|
19909
|
+
const alongCount = gathered >= 0 ? gathered : along2.length;
|
|
19910
|
+
for (let pi = 0; pi < alongCount; pi++) {
|
|
19911
|
+
const p = along2[pi];
|
|
19491
19912
|
if (counts) counts.partVisits++;
|
|
19492
19913
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
19493
19914
|
if (partSphereMiss(lo, ld, p, maxDist)) continue;
|
|
@@ -19496,7 +19917,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19496
19917
|
counts.shapeTested.add(o.id);
|
|
19497
19918
|
}
|
|
19498
19919
|
const r = rayPartInto(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
|
|
19499
|
-
if (r && r.t0 < 0 && r.t1 > 0 && p.st.chipped?.length && inGap(p, toLocal(p.pos, p.q, objLocal(o, origin)))) {
|
|
19920
|
+
if ((passed || skip.body) && r && r.t0 < 0 && r.t1 > 0 && p.st.chipped?.length && inGap(p, toLocal(p.pos, p.q, objLocal(o, origin)))) {
|
|
19500
19921
|
r.t0 = 0;
|
|
19501
19922
|
r.n = vec.scale(d, -1);
|
|
19502
19923
|
}
|
|
@@ -19529,18 +19950,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19529
19950
|
}
|
|
19530
19951
|
}
|
|
19531
19952
|
if (!best || r.t0 < best.distance) {
|
|
19532
|
-
|
|
19533
|
-
|
|
19534
|
-
|
|
19535
|
-
|
|
19953
|
+
if (p.castIn) {
|
|
19954
|
+
const point = vec.madd(origin, d, r.t0);
|
|
19955
|
+
const normal = copyOf(r.n);
|
|
19956
|
+
const member = castMemberAt(o, { p, point, normal, dir: d, pathLen: r.t1 - r.t0 }, origin, d);
|
|
19957
|
+
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);
|
|
19958
|
+
} else {
|
|
19959
|
+
rayPoint[0] = origin[0] + d[0] * r.t0;
|
|
19960
|
+
rayPoint[1] = origin[1] + d[1] * r.t0;
|
|
19961
|
+
rayPoint[2] = origin[2] + d[2] * r.t0;
|
|
19962
|
+
best = keepBest(into, o.id, p.spec.id, rayPoint, r.n, r.t0, r.t1 - r.t0);
|
|
19963
|
+
}
|
|
19536
19964
|
}
|
|
19537
19965
|
}
|
|
19538
19966
|
}
|
|
19539
|
-
|
|
19967
|
+
const hosted = worldOnly ? NO_IMPLS : scope ? scope.impls : implsInOrder();
|
|
19968
|
+
for (let ii = 0; ii < hosted.length; ii++) {
|
|
19969
|
+
const im = hosted[ii];
|
|
19540
19970
|
if (counts) counts.objectVisits++;
|
|
19541
19971
|
if (!scope && broadPhase && rayMissesBounds(origin, d, maxDist, implBoundsOf(im))) continue;
|
|
19542
19972
|
let boxHit = null;
|
|
19543
|
-
|
|
19973
|
+
const implParts2 = scope?.implParts.get(im) ?? im.impl.describe().parts;
|
|
19974
|
+
for (let si = 0; si < implParts2.length; si++) {
|
|
19975
|
+
const ps = implParts2[si];
|
|
19544
19976
|
if (counts) counts.partVisits++;
|
|
19545
19977
|
if (ignore?.has(`${im.impl.id}\0${ps.id}`)) continue;
|
|
19546
19978
|
if (counts) {
|
|
@@ -19561,8 +19993,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19561
19993
|
const far = best ? Math.min(maxDist, best.distance) : maxDist;
|
|
19562
19994
|
const implId = im.impl.id;
|
|
19563
19995
|
const s = im.impl.surfaceRay({ origin, direction: d, maxDistance: far, ...ignore ? { ignored: (part) => ignore.has(`${implId}\0${part}`) } : {} });
|
|
19564
|
-
if (s && (!best || s.distance < best.distance)) best =
|
|
19565
|
-
} else if (!best || boxHit.distance < best.distance) best = boxHit;
|
|
19996
|
+
if (s && (!best || s.distance < best.distance)) best = keepBest(into, implId, s.part, s.point, s.normal, s.distance, s.pathLen);
|
|
19997
|
+
} else if (!best || boxHit.distance < best.distance) best = into ? keepBest(into, boxHit.object, boxHit.part, boxHit.point, boxHit.normal, boxHit.distance, boxHit.pathLen) : boxHit;
|
|
19566
19998
|
}
|
|
19567
19999
|
return best;
|
|
19568
20000
|
};
|
|
@@ -20662,7 +21094,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20662
21094
|
for (const i of out) worn[i] = -1;
|
|
20663
21095
|
return knockOutUnits(o, p, point, energy, out, src);
|
|
20664
21096
|
};
|
|
20665
|
-
const knockOutUnits = (o, p, wp, energy, out, src, d, drive = CHIP_DRIVE) => {
|
|
21097
|
+
const knockOutUnits = (o, p, wp, energy, out, src, d, drive = CHIP_DRIVE, severed) => {
|
|
20666
21098
|
var _a, _b;
|
|
20667
21099
|
const [u, v] = planeAxes(p.thin);
|
|
20668
21100
|
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
@@ -20707,7 +21139,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20707
21139
|
setStage(o, p, 1, {}, src);
|
|
20708
21140
|
const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
|
|
20709
21141
|
const units = cells.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
|
|
20710
|
-
emit({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units });
|
|
21142
|
+
emit({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units, ...severed ? { severed } : {} });
|
|
20711
21143
|
debris(o, p, p.mat.breakDebris, center, vec.normalize(vec.sub(center, wp), [0, 1, 0]), 14, 3, src);
|
|
20712
21144
|
const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
|
|
20713
21145
|
if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
|
|
@@ -20727,12 +21159,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20727
21159
|
const grid = gridOf(p);
|
|
20728
21160
|
const gone = p.rt.chips ?? {};
|
|
20729
21161
|
const worn = (_a = p.rt).bands ?? (_a.bands = {});
|
|
21162
|
+
const [u, v] = [0, 1, 2].filter((k) => k !== along2);
|
|
21163
|
+
const standing = (band) => grid.filter((cell, i) => gone[i] !== -1 && bandOf2(cell.center[along2]) === band);
|
|
21164
|
+
const bearOn = (a, b) => Math.abs(a.center[u] - b.center[u]) < (a.size[u] + b.size[u]) / 2 - 1e-6 && Math.abs(a.center[v] - b.center[v]) < (a.size[v] + b.size[v]) / 2 - 1e-6;
|
|
20730
21165
|
for (const band of new Set(cells.map((cell) => bandOf2(cell.center[along2])))) {
|
|
20731
21166
|
if ((worn[band] ?? 0) >= 1) continue;
|
|
21167
|
+
const left = standing(band);
|
|
20732
21168
|
const center = -p.dims[along2] / 2 + (band + 0.5) * height;
|
|
20733
|
-
if (
|
|
20734
|
-
|
|
20735
|
-
|
|
21169
|
+
if (left.length === 0) {
|
|
21170
|
+
worn[band] = 1;
|
|
21171
|
+
return giveAtCut(o, p, src, { at: alongAt(along2, center), d });
|
|
21172
|
+
}
|
|
21173
|
+
for (const next of [band - 1, band + 1]) {
|
|
21174
|
+
if (next < 0 || next >= bands || (worn[next] ?? 0) >= 1) continue;
|
|
21175
|
+
const beyond = standing(next);
|
|
21176
|
+
if (beyond.length === 0 || left.some((a) => beyond.some((b) => bearOn(a, b)))) continue;
|
|
21177
|
+
worn[band] = 1;
|
|
21178
|
+
worn[next] = 1;
|
|
21179
|
+
return giveAtCut(o, p, src, { at: alongAt(along2, (center + (-p.dims[along2] / 2 + (next + 0.5) * height)) / 2), d });
|
|
21180
|
+
}
|
|
20736
21181
|
}
|
|
20737
21182
|
return false;
|
|
20738
21183
|
};
|
|
@@ -20895,7 +21340,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20895
21340
|
const at2 = vec.madd(origin, d, s * vec.length(d));
|
|
20896
21341
|
debris(o, p, "sparks", at2, vec.scale(d, -1), 6, 3, src);
|
|
20897
21342
|
});
|
|
20898
|
-
if (severed
|
|
21343
|
+
if (severed === 0) return;
|
|
21344
|
+
reyield(o, p, barsMoment(p), src);
|
|
21345
|
+
if (barsMoment(p) <= 0) dropAboveCut(o, p, origin, src);
|
|
21346
|
+
};
|
|
21347
|
+
const dropAboveCut = (o, p, wp, src) => {
|
|
21348
|
+
const cut = p.rt.hinges?.reduce((low, h) => Math.min(low, h.point[1]), Infinity) ?? Infinity;
|
|
21349
|
+
if (!Number.isFinite(cut)) return;
|
|
21350
|
+
const gone = p.rt.chips ?? {};
|
|
21351
|
+
const grid = gridOf(p);
|
|
21352
|
+
const above = grid.flatMap((cell, i) => gone[i] !== -1 && vec.add(p.pos, rotateVec(p.q, cell.center))[1] > cut ? [i] : []);
|
|
21353
|
+
if (above.length === 0) return;
|
|
21354
|
+
const ax = [rotateVec(p.q, [1, 0, 0])[1], rotateVec(p.q, [0, 1, 0])[1], rotateVec(p.q, [0, 0, 1])[1]];
|
|
21355
|
+
const floor = Math.min(...above.map((i) => {
|
|
21356
|
+
const cell = grid[i];
|
|
21357
|
+
return vec.add(p.pos, rotateVec(p.q, cell.center))[1] - (Math.abs(ax[0]) * cell.size[0] + Math.abs(ax[1]) * cell.size[1] + Math.abs(ax[2]) * cell.size[2]) / 2;
|
|
21358
|
+
}));
|
|
21359
|
+
knockOutUnits(o, p, wp, 0, above, src, [0, -1, 0], 0, { point: [p.pos[0], floor, p.pos[2]], normal: [0, 1, 0] });
|
|
20899
21360
|
};
|
|
20900
21361
|
const giveAtCut = (o, p, src, cut) => {
|
|
20901
21362
|
if (!p.spec.reinforcement || !p.spec.units || !p.st.chipped?.length || sectionLoss(p) <= 0) return false;
|
|
@@ -20989,7 +21450,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20989
21450
|
const unitPlan = p.spec.units ? unitFragmentPlan(p, maxFragments * UNIT_FRAGMENT_FACTOR) : [];
|
|
20990
21451
|
const axis = style === "splinter" || style === "snap" ? severAxis(p) : -1;
|
|
20991
21452
|
const cutAt2 = axis < 0 ? void 0 : p.rt.cutAt ?? (origin ? hitLocal[axis] : void 0);
|
|
20992
|
-
const
|
|
21453
|
+
const woodForm = p.mat.splitForm === "slivers" || p.mat.splitForm === "plies" || p.mat.splitForm === "granules" ? p.mat.splitForm : void 0;
|
|
21454
|
+
const planRnd = woodForm ? splitStream(o.id, p.spec.id, hitLocal) : rnd;
|
|
20993
21455
|
const plan = unitPlan.length > 0 ? unitPlan : planFragments({
|
|
20994
21456
|
style,
|
|
20995
21457
|
dims: p.dims,
|
|
@@ -21000,7 +21462,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21000
21462
|
maxFragments,
|
|
21001
21463
|
rnd: planRnd,
|
|
21002
21464
|
sheet: p.mat.sheet,
|
|
21003
|
-
...
|
|
21465
|
+
...woodForm ? { form: woodForm } : {},
|
|
21004
21466
|
...cutAt2 !== void 0 ? { cut: { at: cutAt2, gap: SEVER_BAND } } : {},
|
|
21005
21467
|
...p.spec.solids ? { solids: p.spec.solids } : {}
|
|
21006
21468
|
});
|
|
@@ -21663,7 +22125,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21663
22125
|
if (!r?.part) continue;
|
|
21664
22126
|
reportShelter(o, r);
|
|
21665
22127
|
out.push(r);
|
|
21666
|
-
for (const [part,
|
|
22128
|
+
for (const [part, factor2] of Object.entries(r.blast?.parts ?? {})) summary2.push({ object: o.id, part, factor: factor2 });
|
|
21667
22129
|
fragmentHits += r.blast?.fragmentHits ?? 0;
|
|
21668
22130
|
}
|
|
21669
22131
|
for (const im of impls.values()) {
|
|
@@ -22550,6 +23012,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22550
23012
|
finishExplosions();
|
|
22551
23013
|
const id = opts.id ?? impl.id;
|
|
22552
23014
|
if (taken(id)) throw new Error(`object "${id}" already exists`);
|
|
23015
|
+
implsRevision++;
|
|
22553
23016
|
impls.set(id, { impl, position: opts.position ?? [0, 0, 0], rotation: opts.rotation ?? [0, 0, 0, 1], poses: /* @__PURE__ */ new Map(), posesVersion: 0 });
|
|
22554
23017
|
return id;
|
|
22555
23018
|
},
|
|
@@ -22571,6 +23034,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22571
23034
|
poseVersion++;
|
|
22572
23035
|
objectPoses.set(o, (objectPoses.get(o) ?? 0) + 1);
|
|
22573
23036
|
updateBound(o);
|
|
23037
|
+
markMoved(o);
|
|
22574
23038
|
if (o.hosted && (o.hostedHosts?.has(partId) || p.spec.hostedIn !== void 0 && p.st.exposed !== true)) dirtyHosted.add(o);
|
|
22575
23039
|
},
|
|
22576
23040
|
remove(id) {
|
|
@@ -22580,6 +23044,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22580
23044
|
if (existing) dirtyHosted.delete(existing);
|
|
22581
23045
|
dropObject(id);
|
|
22582
23046
|
impls.delete(id);
|
|
23047
|
+
implsRevision++;
|
|
22583
23048
|
},
|
|
22584
23049
|
has: (id) => taken(id),
|
|
22585
23050
|
ids: () => [...objects.keys(), ...impls.keys()],
|
|
@@ -22715,6 +23180,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22715
23180
|
const terrain = objects.get(r.object)?.parts.find((p) => p.spec.id === r.part)?.spec.tags?.includes("terrain") === true;
|
|
22716
23181
|
return { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: r.distance, ...terrain ? { terrain: true } : {} };
|
|
22717
23182
|
},
|
|
23183
|
+
raycastInto(origin, direction, maxDistance, out, options2) {
|
|
23184
|
+
const ignoredParts = options2?.ignoreParts;
|
|
23185
|
+
const ignore = ignoredParts?.length ? new Set(ignoredParts.map((ignored) => `${ignored.object}\0${ignored.part}`)) : void 0;
|
|
23186
|
+
bestInto = bestScratch;
|
|
23187
|
+
let r;
|
|
23188
|
+
try {
|
|
23189
|
+
r = raycastInternal(origin, direction, maxDistance, ignore, false, true, options2);
|
|
23190
|
+
} finally {
|
|
23191
|
+
bestInto = null;
|
|
23192
|
+
}
|
|
23193
|
+
if (!r) return false;
|
|
23194
|
+
out.object = r.object;
|
|
23195
|
+
out.part = r.part;
|
|
23196
|
+
out.point[0] = r.point[0];
|
|
23197
|
+
out.point[1] = r.point[1];
|
|
23198
|
+
out.point[2] = r.point[2];
|
|
23199
|
+
out.normal[0] = r.normal[0];
|
|
23200
|
+
out.normal[1] = r.normal[1];
|
|
23201
|
+
out.normal[2] = r.normal[2];
|
|
23202
|
+
out.distance = r.distance;
|
|
23203
|
+
out.terrain = isTerrainPart(r.object, r.part);
|
|
23204
|
+
return true;
|
|
23205
|
+
},
|
|
22718
23206
|
sweepBox(box4, direction, distance2, options2 = {}) {
|
|
22719
23207
|
const d = vec.normalize(direction);
|
|
22720
23208
|
const ignoredIds = options2.ignore === void 0 ? [] : typeof options2.ignore === "string" ? [options2.ignore] : options2.ignore;
|
|
@@ -22973,7 +23461,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22973
23461
|
...p.spec.shape.kind === "cylinder" ? { round: true } : {}
|
|
22974
23462
|
}));
|
|
22975
23463
|
const joints = o.joints.filter((j) => ids.has(j.spec.a) && ids.has(j.spec.b) && (!j.st.open || lost.has(j.spec.a) || lost.has(j.spec.b))).map((j) => ({ a: j.spec.a, b: j.spec.b, kind: j.spec.kind, position: j.pos }));
|
|
22976
|
-
return assemblyFlex({ parts: parts2, joints, lost: [...lost], ...options2?.loads ? { loads: options2.loads } : {}, ...options2?.friction !== void 0 ? { friction: options2.friction } : {} });
|
|
23464
|
+
return assemblyFlex({ parts: parts2, joints, lost: [...lost], ...options2?.loads ? { loads: options2.loads } : {}, ...options2?.friction !== void 0 ? { friction: options2.friction } : {}, ...options2?.linear ? { linear: options2.linear } : {} });
|
|
22977
23465
|
},
|
|
22978
23466
|
reset(id) {
|
|
22979
23467
|
finishExplosions();
|
|
@@ -23294,17 +23782,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23294
23782
|
return new Map(w.state(id).parts.map((p) => [p.id, p.flexure ?? 0]));
|
|
23295
23783
|
};
|
|
23296
23784
|
const base2 = bending(out);
|
|
23297
|
-
const
|
|
23785
|
+
const factor2 = new Map(targets.map((p) => [p.id, (base2.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
|
|
23298
23786
|
if (options.redundancy !== void 0) {
|
|
23299
23787
|
const roles = options.redundancyRoles ?? ["column"];
|
|
23300
23788
|
for (const lost of out.parts) {
|
|
23301
23789
|
if (!lost.structure || !roles.includes(lost.structure.role)) continue;
|
|
23302
23790
|
const l = bending(without(out, lost.id));
|
|
23303
|
-
for (const p of targets) if (p.id !== lost.id)
|
|
23791
|
+
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));
|
|
23304
23792
|
}
|
|
23305
23793
|
}
|
|
23306
23794
|
for (const p of targets) {
|
|
23307
|
-
const f =
|
|
23795
|
+
const f = factor2.get(p.id);
|
|
23308
23796
|
const g = bendGeometry(p);
|
|
23309
23797
|
if (f <= 1 || g.gravity < 0) continue;
|
|
23310
23798
|
const section = { b: sectionWidth(g, g.gravity), h: g.dims[g.gravity] };
|
|
@@ -24215,6 +24703,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24215
24703
|
else slab.y0 = round2(slab.y1 - thickness);
|
|
24216
24704
|
slab.mass = Math.max(1, Math.round((slab.aabb[2] - slab.aabb[0]) * (slab.aabb[3] - slab.aabb[1]) * (slab.y1 - slab.y0) * densityOf(slab.material)));
|
|
24217
24705
|
};
|
|
24706
|
+
function footprintWithin(leaf, footprint) {
|
|
24707
|
+
const out = [];
|
|
24708
|
+
for (const r of footprint) {
|
|
24709
|
+
const cut = [Math.max(leaf[0], r[0]), Math.max(leaf[1], r[1]), Math.min(leaf[2], r[2]), Math.min(leaf[3], r[3])];
|
|
24710
|
+
if (cut[2] - cut[0] > 1e-6 && cut[3] - cut[1] > 1e-6) out.push(cut);
|
|
24711
|
+
}
|
|
24712
|
+
return out;
|
|
24713
|
+
}
|
|
24218
24714
|
function cutSlab(context, slab, wallBoxes) {
|
|
24219
24715
|
const { options } = context;
|
|
24220
24716
|
const roof = slab.cover === true;
|
|
@@ -24243,7 +24739,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24243
24739
|
floor: slab.floor,
|
|
24244
24740
|
...slab.cover ? { cover: true } : {},
|
|
24245
24741
|
slab: slab.id,
|
|
24246
|
-
...slab.footprint ? { footprint: slab.footprint } : {}
|
|
24742
|
+
...slab.footprint ? { footprint: footprintWithin(leaf, slab.footprint) } : {}
|
|
24247
24743
|
})
|
|
24248
24744
|
);
|
|
24249
24745
|
context.parts.splice(context.parts.indexOf(slab), 1, ...panels);
|
|
@@ -24728,7 +25224,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24728
25224
|
return spec;
|
|
24729
25225
|
};
|
|
24730
25226
|
var MEMBER_CAGE = { spacing: 0.1, diameter: 0.01, unit: 0.1 };
|
|
24731
|
-
var CAGED_ROLES = /* @__PURE__ */ new Set(["beam", "column"]);
|
|
25227
|
+
var CAGED_ROLES = /* @__PURE__ */ new Set(["beam", "column", "slab"]);
|
|
24732
25228
|
var CAGE_COVER = 0.03;
|
|
24733
25229
|
var CAGE_BUCKLING_SHARE = 0.5;
|
|
24734
25230
|
var DEFAULT_RESIDUAL = 0.15;
|
|
@@ -25006,15 +25502,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25006
25502
|
const pier = (clear - win) / 2;
|
|
25007
25503
|
const at2 = (u) => along2 === 0 ? [u, 0, fixed] : [fixed, 0, u];
|
|
25008
25504
|
const size = (u, h) => along2 === 0 ? [u, h, c.thickness] : [c.thickness, h, u];
|
|
25009
|
-
const
|
|
25505
|
+
const put2 = (name, u, h, y, centreU, on) => {
|
|
25010
25506
|
const p = at2(centreU);
|
|
25011
25507
|
wall(`infill_${f}_${side}_${k}_${name}`, size(u, h), [p[0], y, p[2]], on);
|
|
25012
25508
|
};
|
|
25013
25509
|
const id = (name) => `infill_${f}_${side}_${k}_${name}`;
|
|
25014
|
-
|
|
25015
|
-
|
|
25016
|
-
|
|
25017
|
-
|
|
25510
|
+
put2("sill", clear, sill, yb + sill / 2, centre2, [c1, c2]);
|
|
25511
|
+
put2("pl", pier, head - sill, yb + sill + (head - sill) / 2, centre2 - clear / 2 + pier / 2, [c1, id("sill")]);
|
|
25512
|
+
put2("pr", pier, head - sill, yb + sill + (head - sill) / 2, centre2 + clear / 2 - pier / 2, [c2, id("sill")]);
|
|
25513
|
+
put2("head", clear, room - head, yb + head + (room - head) / 2, centre2, [c1, c2]);
|
|
25018
25514
|
const gp = at2(centre2);
|
|
25019
25515
|
const gid = `glass_${f}_${side}_${k}`;
|
|
25020
25516
|
parts2.push({
|
|
@@ -25104,24 +25600,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25104
25600
|
const floor = `slab_${level - 1}`;
|
|
25105
25601
|
const y = storeyBase(g, level);
|
|
25106
25602
|
const shafts = options.shafts ?? [];
|
|
25107
|
-
const
|
|
25603
|
+
const put2 = (id, material, size, at2, mass, extra = {}) => {
|
|
25108
25604
|
parts2.push({ id: id + sfx, material, shape: box3(size), position: [at2[0], y + size[1] / 2, at2[1]], mass, fill: 0.2, structure: { role: "partition" }, tags: ["mechanical"], ...extra });
|
|
25109
25605
|
rests(joints, id + sfx, floor, "bolt");
|
|
25110
25606
|
};
|
|
25111
|
-
shafts.forEach((at2, k) =>
|
|
25607
|
+
shafts.forEach((at2, k) => put2(`machine_${k}`, "steel", [1.2, 1, 0.8], at2, c.machineMass + c.suspendedMass, { tags: ["mechanical", "elevator_machine"] }));
|
|
25112
25608
|
const liters = options.waterLiters ?? towerWater(level, options);
|
|
25113
25609
|
const depth = 2;
|
|
25114
25610
|
const side = Math.sqrt(liters / 1e3 / depth);
|
|
25115
25611
|
const [hx] = slabHalf(g);
|
|
25116
25612
|
const tankAt = options.tankAt ?? [-hx / 2, 0];
|
|
25117
25613
|
const shell = 4 * side * depth + 2 * side * side;
|
|
25118
|
-
|
|
25614
|
+
put2("water_tank", c.tankMaterial, [side, depth, side], tankAt, liters + 1100 * c.tankWall * shell, {
|
|
25119
25615
|
fill: shell * c.tankWall / (side * side * depth),
|
|
25120
25616
|
thickness: c.tankWall,
|
|
25121
25617
|
contains: { fluid: "water", liters },
|
|
25122
25618
|
tags: ["mechanical", "water_tank"]
|
|
25123
25619
|
});
|
|
25124
|
-
for (let k = 0; k < c.chillers; k++)
|
|
25620
|
+
for (let k = 0; k < c.chillers; k++) put2(`chiller_${k}`, "steel", [3, 2, 1.5], [-hx + 2 + k * 3.5, -(slabHalf(g)[1] - 2)], c.chillerMass, { tags: ["mechanical", "chiller"] });
|
|
25125
25621
|
return { ...spec, parts: parts2, joints };
|
|
25126
25622
|
}
|
|
25127
25623
|
var DAMPER_DEFAULTS = { ratio: 0.01, modalShare: 0.25, material: "steel", maxHeight: 2.5 };
|
|
@@ -36773,7 +37269,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
36773
37269
|
stack: 6,
|
|
36774
37270
|
shape: "cup",
|
|
36775
37271
|
color: 14215408,
|
|
36776
|
-
rarity: "common"
|
|
37272
|
+
rarity: "common",
|
|
37273
|
+
parts: [
|
|
37274
|
+
{
|
|
37275
|
+
id: "body",
|
|
37276
|
+
material: "glass",
|
|
37277
|
+
thickness: 3e-3
|
|
37278
|
+
}
|
|
37279
|
+
]
|
|
36777
37280
|
},
|
|
36778
37281
|
{
|
|
36779
37282
|
id: "cutlery",
|
|
@@ -43472,14 +43975,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
43472
43975
|
var ITEM_CONTRACTS = createItemContracts();
|
|
43473
43976
|
var createGoodsKinds = (options = {}) => defineCategories(GOODS_KINDS, options);
|
|
43474
43977
|
var KINDS2 = createGoodsKinds();
|
|
43475
|
-
var
|
|
43978
|
+
var withKind = (item) => {
|
|
43476
43979
|
const kind = item.kind;
|
|
43477
|
-
|
|
43478
|
-
|
|
43980
|
+
if (!kind || !KINDS2.has(kind)) return item;
|
|
43981
|
+
const defaults = KINDS2.defaults(kind);
|
|
43982
|
+
const seal = defaults.seal;
|
|
43983
|
+
const parts2 = defaults.parts;
|
|
43984
|
+
const own = item.parts;
|
|
43985
|
+
return { ...item, ...seal ? { seal: { ...seal, ...item.seal } } : {}, ...!own && parts2 ? { parts: parts2 } : {} };
|
|
43479
43986
|
};
|
|
43480
43987
|
var goodsPack = {
|
|
43481
43988
|
id: "goods",
|
|
43482
|
-
items: GOODS_ITEMS.map(
|
|
43989
|
+
items: GOODS_ITEMS.map(withKind),
|
|
43483
43990
|
categories: GOODS_CATEGORIES,
|
|
43484
43991
|
places: GOODS_PLACES,
|
|
43485
43992
|
containers: GOODS_CONTAINERS,
|
|
@@ -47083,7 +47590,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47083
47590
|
worlds.set(world, info);
|
|
47084
47591
|
return world;
|
|
47085
47592
|
}
|
|
47086
|
-
function
|
|
47593
|
+
function pointOf3(world, fixtureId) {
|
|
47087
47594
|
const info = worlds.get(world);
|
|
47088
47595
|
return info ? info.points.get(fixtureId) : void 0;
|
|
47089
47596
|
}
|
|
@@ -47224,7 +47731,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47224
47731
|
if (info) for (const f of planned.fixtures) info.points.set(f.global, f.point);
|
|
47225
47732
|
return out;
|
|
47226
47733
|
}
|
|
47227
|
-
return { version: ADAPTER_VERSION, household: hh, plan, createWorld, add, blockedOf, pointOf:
|
|
47734
|
+
return { version: ADAPTER_VERSION, household: hh, plan, createWorld, add, blockedOf, pointOf: pointOf3, ownSpec, registries: { typeMap, contentMap, contentByGroup, chairTables, fixturesOfPoint, substitutes, preference, ownTypes } };
|
|
47228
47735
|
}
|
|
47229
47736
|
var FloorplanInteractables = { version: ADAPTER_VERSION, create: create2, TYPE_MAP, CONTENT_MAP, CONTENT_BY_GROUP, CHAIR_TABLES, PREFERENCE, mergeRegistry };
|
|
47230
47737
|
|
|
@@ -47304,21 +47811,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47304
47811
|
{ type: "buffet", category: "buffet", w: 1.6, d: 0.5, h: 0.9, opening: 0.45 },
|
|
47305
47812
|
{ type: "china_cabinet", category: "china_cabinet", w: 1.2, d: 0.45, h: 2, opening: 0.45 },
|
|
47306
47813
|
{ type: "stairs", category: "stairs", w: 1, d: 3.2, h: 2.8 },
|
|
47307
|
-
{ type: "planter_bed", category: "planter_bed", w: 3, d: 0.7, h: 0.4, color: { role: "dirt" } },
|
|
47308
|
-
{ type: "planter_bed_small", category: "planter_bed", w: 1.8, d: 0.6, h: 0.4, color: { role: "dirt" } },
|
|
47814
|
+
{ type: "planter_bed", category: "planter_bed", w: 3, d: 0.7, h: 0.4, color: { role: "dirt" }, material: "concrete" },
|
|
47815
|
+
{ type: "planter_bed_small", category: "planter_bed", w: 1.8, d: 0.6, h: 0.4, color: { role: "dirt" }, material: "concrete" },
|
|
47309
47816
|
{ type: "tree_small", category: "tree", w: 1.2, d: 1.2, h: 3, color: { role: "lawn" } },
|
|
47310
47817
|
{ type: "tree_large", category: "tree_large", w: 3, d: 3, h: 6, color: { role: "lawn" } },
|
|
47311
|
-
{ type: "shrub", category: "shrub", w: 0.8, d: 0.8, h: 0.9, color: { role: "lawn" } },
|
|
47312
|
-
{ type: "outdoor_pot", category: "outdoor_pot", w: 0.5, d: 0.5, h: 0.7 },
|
|
47313
|
-
{ type: "fountain", category: "fountain", w: 2, d: 2, h: 1.2 },
|
|
47818
|
+
{ type: "shrub", category: "shrub", w: 0.8, d: 0.8, h: 0.9, color: { role: "lawn" }, material: "foliage" },
|
|
47819
|
+
{ type: "outdoor_pot", category: "outdoor_pot", w: 0.5, d: 0.5, h: 0.7, material: "ceramic" },
|
|
47820
|
+
{ type: "fountain", category: "fountain", w: 2, d: 2, h: 1.2, material: "concrete" },
|
|
47314
47821
|
{ type: "garden_bench", category: "garden_bench", w: 1.5, d: 0.5, h: 0.5 },
|
|
47315
47822
|
{ type: "clothesline", category: "clothesline", w: 3.6, d: 0.4, h: 2 },
|
|
47316
47823
|
{ type: "bbq_grill", category: "bbq_grill", w: 1, d: 0.7, h: 1.4 },
|
|
47317
47824
|
{ type: "outbuilding", category: "outbuilding", w: 3.2, d: 3, h: 2.6 },
|
|
47318
47825
|
{ type: "doghouse", category: "doghouse", w: 0.6, d: 0.8, h: 0.7 },
|
|
47319
47826
|
{ type: "water_tank", category: "water_tank", w: 1, d: 1, h: 1.8 },
|
|
47320
|
-
{ type: "pool", category: "pool", w: 7, d: 3.5, h: 0, rim: 1.2, color: { role: "water" } },
|
|
47321
|
-
{ type: "pool_large", category: "pool", w: 9, d: 4.5, h: 0, rim: 1.2, color: { role: "water" } },
|
|
47827
|
+
{ type: "pool", category: "pool", w: 7, d: 3.5, h: 0, rim: 1.2, color: { role: "water" }, material: "concrete" },
|
|
47828
|
+
{ type: "pool_large", category: "pool", w: 9, d: 4.5, h: 0, rim: 1.2, color: { role: "water" }, material: "concrete" },
|
|
47322
47829
|
{ type: "sun_lounger", category: "sun_lounger", w: 0.7, d: 2, h: 0.4, deck: true },
|
|
47323
47830
|
{ type: "outdoor_table", category: "outdoor_table", w: 1.6, d: 1, h: 0.75, deck: true },
|
|
47324
47831
|
{ type: "gas_cylinder", category: "gas_cylinder", w: 0.35, d: 0.35, h: 0.6 },
|
|
@@ -47328,12 +47835,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47328
47835
|
{ type: "track_spot", category: "ceiling_light", w: 0.6, d: 0.1, h: 0.12, decor: true, mount: "ceiling", color: { role: "metal" } },
|
|
47329
47836
|
{ type: "chandelier", category: "ceiling_light", w: 0.7, d: 0.7, h: 0.6, decor: true, mount: "ceiling", color: { role: "metal" } },
|
|
47330
47837
|
{ type: "wall_ac", category: "air_conditioner", w: 0.9, d: 0.25, h: 0.28, decor: true, mount: "wall", color: { role: "ceiling" } },
|
|
47331
|
-
{ type: "ac_condenser", category: "ac_condenser", w: 0.8, d: 0.35, h: 0.6, decor: true, mount: "floor", color: { role: "ceiling" } },
|
|
47838
|
+
{ type: "ac_condenser", category: "ac_condenser", w: 0.8, d: 0.35, h: 0.6, decor: true, mount: "floor", color: { role: "ceiling" }, material: "steel" },
|
|
47332
47839
|
{ type: "picture_small", category: "picture", w: 0.4, d: 0.03, h: 0.5, decor: true, mount: "wall", color: { role: "picture_accent" } },
|
|
47333
47840
|
{ type: "picture_large", category: "picture", w: 0.9, d: 0.03, h: 0.6, decor: true, mount: "wall", color: { role: "picture_accent" } },
|
|
47334
|
-
{ type: "mirror", category: "picture", w: 0.6, d: 0.03, h: 0.9, decor: true, mount: "wall", color: { role: "metal" } },
|
|
47335
|
-
{ type: "floor_plant", category: "plant", w: 0.4, d: 0.4, h: 0.9, decor: true, mount: "floor", color: { role: "lawn" } },
|
|
47336
|
-
{ type: "table_plant", category: "plant", w: 0.2, d: 0.2, h: 0.3, decor: true, mount: "support", color: { role: "lawn" } },
|
|
47841
|
+
{ type: "mirror", category: "picture", w: 0.6, d: 0.03, h: 0.9, decor: true, mount: "wall", color: { role: "metal" }, material: "glass" },
|
|
47842
|
+
{ type: "floor_plant", category: "plant", w: 0.4, d: 0.4, h: 0.9, decor: true, mount: "floor", color: { role: "lawn" }, material: "ceramic" },
|
|
47843
|
+
{ type: "table_plant", category: "plant", w: 0.2, d: 0.2, h: 0.3, decor: true, mount: "support", color: { role: "lawn" }, material: "ceramic" },
|
|
47337
47844
|
{ type: "mailbox", category: "mailbox", w: 0.35, d: 0.3, h: 0.3, decor: true, mount: "wall_top", color: { role: "metal" } },
|
|
47338
47845
|
{ type: "table_lamp", category: "table_light", w: 0.36, d: 0.36, h: 0.5, decor: true, mount: "support", powered: true },
|
|
47339
47846
|
{ type: "hanging_plant", category: "plant", w: 0.3, d: 0.3, h: 0.7, decor: true, mount: "ceiling", color: { role: "lawn" } },
|
|
@@ -47348,11 +47855,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47348
47855
|
{ type: "gourmet_counter_small", category: "gourmet", w: 1.8, d: 0.65, h: 1, window: true, equip: ["bbq_grill", "kitchen_cabinet"] },
|
|
47349
47856
|
{ type: "gourmet_table", category: "gourmet", w: 2.8, d: 0.9, h: 0.78 },
|
|
47350
47857
|
{ type: "gourmet_table_small", category: "gourmet", w: 1.2, d: 0.9, h: 0.78 },
|
|
47351
|
-
{ type: "pool_small", category: "pool", w: 5, d: 2.6, h: 0, rim: 1.2, color: { role: "water" } },
|
|
47352
|
-
{ type: "pool_medium", category: "pool", w: 6, d: 3, h: 0, rim: 1.2, color: { role: "water" } },
|
|
47858
|
+
{ type: "pool_small", category: "pool", w: 5, d: 2.6, h: 0, rim: 1.2, color: { role: "water" }, material: "concrete" },
|
|
47859
|
+
{ type: "pool_medium", category: "pool", w: 6, d: 3, h: 0, rim: 1.2, color: { role: "water" }, material: "concrete" },
|
|
47353
47860
|
{ type: "deck", category: "deck", w: 3, d: 2, h: 0.15, flat: true, deck: true, color: { role: "deck_floor" } },
|
|
47354
|
-
{ type: "garden_bed", category: "garden_bed", w: 2, d: 0.8, h: 0.3, color: { role: "dirt" } },
|
|
47355
|
-
{ type: "fruit_tree", category: "tree", w: 2.2, d: 2.2, h: 3.5, color: { role: "lawn" } },
|
|
47861
|
+
{ type: "garden_bed", category: "garden_bed", w: 2, d: 0.8, h: 0.3, color: { role: "dirt" }, material: "concrete" },
|
|
47862
|
+
{ type: "fruit_tree", category: "tree", w: 2.2, d: 2.2, h: 3.5, color: { role: "lawn" }, material: "foliage" },
|
|
47356
47863
|
{ type: "palm_tree", category: "tree", w: 1.2, d: 1.2, h: 4, color: { role: "lawn" } },
|
|
47357
47864
|
{ type: "pergola", category: "pergola", w: 3.6, d: 3.2, h: 2.4, flat: true, mount: "roof", color: { role: "deck_floor" } },
|
|
47358
47865
|
{ type: "bbq_simple", category: "bbq_simple", w: 0.8, d: 0.6, h: 1.2 },
|
|
@@ -48419,7 +48926,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48419
48926
|
}
|
|
48420
48927
|
var residentialTower = residentialTowerTemplate();
|
|
48421
48928
|
|
|
48422
|
-
// ../game-floorplan-three/dist/chunk-
|
|
48929
|
+
// ../game-floorplan-three/dist/chunk-3EJGIA6V.js
|
|
48423
48930
|
var __defProp3 = Object.defineProperty;
|
|
48424
48931
|
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
48425
48932
|
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -48429,6 +48936,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48429
48936
|
"prompt.lockedDoor": "E: locked door",
|
|
48430
48937
|
"prompt.lightOn": "E: turn on the light",
|
|
48431
48938
|
"prompt.lightOff": "E: turn off the light",
|
|
48939
|
+
"prompt.sit": "E: sit",
|
|
48940
|
+
"prompt.lie": "E: lie down",
|
|
48432
48941
|
"what.door": "the door",
|
|
48433
48942
|
"what.curtain": "the curtain",
|
|
48434
48943
|
"what.mailbox": "the mailbox",
|
|
@@ -48455,6 +48964,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48455
48964
|
"prompt.lockedDoor": "E: porta trancada",
|
|
48456
48965
|
"prompt.lightOn": "E: acender a luz",
|
|
48457
48966
|
"prompt.lightOff": "E: apagar a luz",
|
|
48967
|
+
"prompt.sit": "E: sentar",
|
|
48968
|
+
"prompt.lie": "E: deitar",
|
|
48458
48969
|
"what.door": "a porta",
|
|
48459
48970
|
"what.curtain": "a cortina",
|
|
48460
48971
|
"what.mailbox": "a caixa de correio",
|
|
@@ -48706,7 +49217,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48706
49217
|
try {
|
|
48707
49218
|
for (const { b, shut } of pieces) {
|
|
48708
49219
|
shutFaces = shut;
|
|
48709
|
-
|
|
49220
|
+
put2(mat, "box", (b[0] + b[3]) / 2, (b[1] + b[4]) / 2, (b[2] + b[5]) / 2, _qi, b[3] - b[0], b[4] - b[1], b[5] - b[2], color2);
|
|
48710
49221
|
}
|
|
48711
49222
|
} finally {
|
|
48712
49223
|
shared2.ctx.keepOut = taken.length ? taken : void 0;
|
|
@@ -48715,7 +49226,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48715
49226
|
}
|
|
48716
49227
|
return true;
|
|
48717
49228
|
}
|
|
48718
|
-
function
|
|
49229
|
+
function put2(mat, geo, px, py, pz, q, sx, sy, sz, color2, uvr) {
|
|
48719
49230
|
if ((shared2.ctx.keepOut || shared2.ctx.itemBoxes) && geo === "box" && !uvr && keptOut(mat, px, py, pz, q, sx, sy, sz, color2)) return;
|
|
48720
49231
|
if (shared2.ctx.blockBoxes && geo === "box" && mat !== "emissive" && mat !== "glass" && Math.abs(q.x) + Math.abs(q.y) + Math.abs(q.z) < 1e-9) shared2.ctx.blockBoxes.push([px - sx / 2, py - sy / 2, pz - sz / 2, px + sx / 2, py + sy / 2, pz + sz / 2]);
|
|
48721
49232
|
{
|
|
@@ -48809,16 +49320,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48809
49320
|
function boxC(mat, cx, cy, cz, sx, sy, sz, color2, rx = 0, ry = 0, rz = 0, uvr) {
|
|
48810
49321
|
if (rx || ry || rz) _q.setFromEuler(_e.set(rx, ry, rz, "YXZ"));
|
|
48811
49322
|
else _q.identity();
|
|
48812
|
-
|
|
49323
|
+
put2(mat, "box", cx, cy, cz, _q, sx, sy, sz, color2, uvr);
|
|
48813
49324
|
}
|
|
48814
49325
|
function bxBase(mat, x0, y0, z0, x1, y1, z1, color2) {
|
|
48815
49326
|
if (x1 - x0 < 1e-4 || y1 - y0 < 1e-4 || z1 - z0 < 1e-4) return;
|
|
48816
49327
|
_q.identity();
|
|
48817
|
-
|
|
49328
|
+
put2(mat, "box", (x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2, _q, x1 - x0, y1 - y0, z1 - z0, color2);
|
|
48818
49329
|
}
|
|
48819
49330
|
function cylBase(mat, x, y, z, r, h, color2, seg2 = "cyl") {
|
|
48820
49331
|
_q.identity();
|
|
48821
|
-
|
|
49332
|
+
put2(mat, seg2, x, y + h / 2, z, _q, r * 2, h, r * 2, color2);
|
|
48822
49333
|
}
|
|
48823
49334
|
function polyFace(mat, pts, color2, hint) {
|
|
48824
49335
|
const A = accFor(mat), n = pts.length, O = cursor.org, RY = cursor.ry;
|
|
@@ -48882,7 +49393,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48882
49393
|
const setBx = (f) => {
|
|
48883
49394
|
bxImpl = f;
|
|
48884
49395
|
};
|
|
48885
|
-
const defined = { GEO, UV_SCALE, WITH_MAP, Accumulator, cursor, PARTS, MIRRORS, part, applyPart, _Y, _qa, _qb, pieceRecord, structurePiece, accFor, _q, _e, _col, rgbOf, put, boxC, bx, getBx, setBx, cylBase, polyFace };
|
|
49396
|
+
const defined = { GEO, UV_SCALE, WITH_MAP, Accumulator, cursor, PARTS, MIRRORS, part, applyPart, _Y, _qa, _qb, pieceRecord, structurePiece, accFor, _q, _e, _col, rgbOf, put: put2, boxC, bx, getBx, setBx, cylBase, polyFace };
|
|
48886
49397
|
Object.assign(K, defined);
|
|
48887
49398
|
}
|
|
48888
49399
|
function installKernelNoise(K, _shared) {
|
|
@@ -50977,7 +51488,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
50977
51488
|
Object.assign(K, defined);
|
|
50978
51489
|
}
|
|
50979
51490
|
function installRoofTiles(K, shared2) {
|
|
50980
|
-
const { UV_SCALE, _Y, _h2, _q, accFor, cursor, put, rgbOf, structurePiece } = K;
|
|
51491
|
+
const { UV_SCALE, _Y, _h2, _q, accFor, cursor, put: put2, rgbOf, structurePiece } = K;
|
|
50981
51492
|
const sh = (...a) => K.sh(...a);
|
|
50982
51493
|
const R_STYLE = () => shared2.ctx.r && shared2.ctx.r.style || "budget";
|
|
50983
51494
|
function tileRelief(mat, pts, color2, type, origin) {
|
|
@@ -51115,10 +51626,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
51115
51626
|
const colonial = type !== "fiber_cement", r = colonial ? 0.085 : 0.075, c = sh(roofColor, colonial ? 0.82 : 0.9), lift = colonial ? 0.05 : 0.035;
|
|
51116
51627
|
_q.setFromUnitVectors(_Y, K._v3.set(dx / Ln, dy / Ln, dz / Ln));
|
|
51117
51628
|
const mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2 + lift, mz = (a[2] + b[2]) / 2;
|
|
51118
|
-
|
|
51629
|
+
put2("plain", colonial ? "cyl" : "cyl6", mx, my, mz, _q, r * 2, Ln, r * 2, c);
|
|
51119
51630
|
if (colonial) for (let t = 0.25; t < Ln - 0.1; t += 0.42) {
|
|
51120
51631
|
const f = t / Ln;
|
|
51121
|
-
|
|
51632
|
+
put2("plain", "cyl", a[0] + dx * f, a[1] + dy * f + lift, a[2] + dz * f, _q, r * 2.25, 0.035, r * 2.25, sh(c, 0.7));
|
|
51122
51633
|
}
|
|
51123
51634
|
}
|
|
51124
51635
|
function pieceOfPane(x, z) {
|
|
@@ -52597,7 +53108,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52597
53108
|
var UNDER_SINK_VALVE_RISE = 0.1;
|
|
52598
53109
|
var pipeMass = (diameter, length) => DENSITY.plastic * Math.PI * (diameter / 2) ** 2 * length * PIPE_WALL_FILL;
|
|
52599
53110
|
function installUtilitiesWater(K, shared2) {
|
|
52600
|
-
const { THREE, _Y, _q, cursor, cylBase, part, pieceRecord, put } = K;
|
|
53111
|
+
const { THREE, _Y, _q, cursor, cylBase, part, pieceRecord, put: put2 } = K;
|
|
52601
53112
|
function createWater(r, state) {
|
|
52602
53113
|
const H = r.utilities?.plumbing, cap = H ? +H.capacityL || 0 : 0, ls = { dry: [], full: [] }, points = {}, itemPoint = {};
|
|
52603
53114
|
if (H) for (const p of H.points) {
|
|
@@ -52684,7 +53195,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52684
53195
|
const dx = b[0] - a[0], dy = b[1] - a[1], dz = b[2] - a[2], L = Math.hypot(dx, dy, dz);
|
|
52685
53196
|
if (L < 1e-3) return;
|
|
52686
53197
|
_q.setFromUnitVectors(_Y, _v3.set(dx / L, dy / L, dz / L));
|
|
52687
|
-
|
|
53198
|
+
put2("plain", "cyl", (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2, _q, diameter, L, diameter, color2);
|
|
52688
53199
|
}
|
|
52689
53200
|
const _v3 = new THREE.Vector3();
|
|
52690
53201
|
function layWallRun({ id, routes, diameter, group, meta }) {
|
|
@@ -52949,7 +53460,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52949
53460
|
var END_RENDER = 0.02;
|
|
52950
53461
|
var SLIVER_CLEAR = 5e-4;
|
|
52951
53462
|
var MORTAR_LIFT = 9e-3;
|
|
52952
|
-
function layUnits(rect, coursing,
|
|
53463
|
+
function layUnits(rect, coursing, put2) {
|
|
52953
53464
|
const { courseH, unitLen, joint, courseBase } = coursing;
|
|
52954
53465
|
const first = Math.floor((rect.y0 - courseBase) / courseH + 1e-6);
|
|
52955
53466
|
for (let row = first; courseBase + row * courseH < rect.y1 - 1e-6; row++) {
|
|
@@ -52969,7 +53480,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52969
53480
|
units[units.length - 1][1] = rect.a1;
|
|
52970
53481
|
if (units.length > 1 && units[0][1] - units[0][0] < MIN_PIECE2) units.splice(0, 2, [rect.a0, units[1][1]]);
|
|
52971
53482
|
if (units.length > 1 && units[units.length - 1][1] - units[units.length - 1][0] < MIN_PIECE2) units.splice(units.length - 2, 2, [units[units.length - 2][0], rect.a1]);
|
|
52972
|
-
for (const [b0, b1] of units)
|
|
53483
|
+
for (const [b0, b1] of units) put2(b0, ya, b1, yb);
|
|
52973
53484
|
}
|
|
52974
53485
|
}
|
|
52975
53486
|
function coreWidthOf(thickness, unitId) {
|
|
@@ -53546,7 +54057,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
53546
54057
|
var FLOOR_SLAB_UNDERSIDE = 0.24;
|
|
53547
54058
|
var BOX_COLOR = 15381256;
|
|
53548
54059
|
function installUtilitiesElectrical(K, shared2) {
|
|
53549
|
-
const { _Y, _q, _v3, bx, cursor, cylBase, part, pieceRecord, put } = K;
|
|
54060
|
+
const { _Y, _q, _v3, bx, cursor, cylBase, part, pieceRecord, put: put2 } = K;
|
|
53550
54061
|
const sh = (...a) => K.sh(...a);
|
|
53551
54062
|
function electricalStructure() {
|
|
53552
54063
|
const R = shared2.ctx.r, E = R.utilities?.electrical;
|
|
@@ -53558,7 +54069,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
53558
54069
|
const L = Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
|
|
53559
54070
|
if (L < 1e-3) return;
|
|
53560
54071
|
_q.setFromUnitVectors(_Y, _v3.set((b[0] - a[0]) / L, (b[1] - a[1]) / L, (b[2] - a[2]) / L));
|
|
53561
|
-
|
|
54072
|
+
put2("plain", "cyl", (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2, _q, r_ * 2, L, r_ * 2, wireRun);
|
|
53562
54073
|
};
|
|
53563
54074
|
const pole = (u, v, h) => {
|
|
53564
54075
|
const buried = postEmbedment(h), below = shared2.ctx.visorScene ? 0 : buried;
|
|
@@ -53820,7 +54331,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
53820
54331
|
const dx = b[0] - a[0], dy = b[1] - a[1], dz = b[2] - a[2], L = Math.hypot(dx, dy, dz);
|
|
53821
54332
|
if (L < 1e-3) return;
|
|
53822
54333
|
_q.setFromUnitVectors(_Y, _v3.set(dx / L, dy / L, dz / L));
|
|
53823
|
-
|
|
54334
|
+
put2("plain", "cyl", (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2, _q, diameter, L, diameter, color2);
|
|
53824
54335
|
}
|
|
53825
54336
|
const defined = { electricalStructure, pipe2 };
|
|
53826
54337
|
Object.assign(K, defined);
|
|
@@ -54073,7 +54584,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
54073
54584
|
Object.assign(K, defined);
|
|
54074
54585
|
}
|
|
54075
54586
|
function installFurnitureApi(K, shared2) {
|
|
54076
|
-
const { _e, _h2, _q, boxC, cursor, macroGround, polyFace, put } = K;
|
|
54587
|
+
const { _e, _h2, _q, boxC, cursor, macroGround, polyFace, put: put2 } = K;
|
|
54077
54588
|
const MATERIAL_MAP2 = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", foam: "fabric", plant: "plant", water: "water", emissive: "emissive", "atlas_picture": "picture", "atlas_floor": "floor", plaster: "plain", matte: "glass", glass_light: "emissive", light: "emissive", ceramic_tile: "plain", parquet: "plain", ceramic: "plain" };
|
|
54078
54589
|
const mm = (k) => MATERIAL_MAP2[k] || "plain";
|
|
54079
54590
|
const LIGHTS = [];
|
|
@@ -54090,7 +54601,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
54090
54601
|
cylinder(M, mat, x, y, z, r, h, color2, rx = 0, rz = 0, seg2) {
|
|
54091
54602
|
const [px, pz] = loc(M, x, z);
|
|
54092
54603
|
_q.setFromEuler(_e.set(rx || 0, M.ry, rz || 0, "YXZ"));
|
|
54093
|
-
|
|
54604
|
+
put2(mm(mat), seg2 || "cyl", px, M.base + y + (rx || rz ? 0 : h / 2), pz, _q, r * 2, h, r * 2, color2);
|
|
54094
54605
|
},
|
|
54095
54606
|
leaf(M, x, y, z, w, h, color2, ry = 0, rx = 0) {
|
|
54096
54607
|
const [px, pz] = loc(M, x, z), a = M.ry + (ry || 0), ca = Math.cos(a), sa = Math.sin(a), t1 = (rx || 0) * 0.8, t2 = (rx || 0) * 1.5, y0 = M.base + y;
|
|
@@ -54111,12 +54622,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
54111
54622
|
if (uv && mat === "atlas_floor") {
|
|
54112
54623
|
const col = Math.floor(uv.u0 * 4 + 1e-6), lin = uv.v0 < 0.5 ? 1 : 0, cell = col + 4 * lin, h0 = _h2(Math.round(px * 8), Math.round(pz * 8)), type = cell === 5 ? "dirt" : cell === 0 || cell === 1 ? "lawn" : null;
|
|
54113
54624
|
if (type === "dirt") {
|
|
54114
|
-
|
|
54625
|
+
put2("dirt", "plane", px, M.base + y, pz, _q, w, h, 1, sh(color2, 1 / 0.965));
|
|
54115
54626
|
return;
|
|
54116
54627
|
}
|
|
54117
54628
|
if (type) uv = { u0: uv.u0, u1: uv.u1, v0: uv.v0, v1: uv.v1, rot: h0 * 4 | 0, fx: h0 > 0.5 ? 1 : 0, vc: (wx, wz) => macroGround(wx, wz, type) };
|
|
54118
54629
|
}
|
|
54119
|
-
|
|
54630
|
+
put2(mm(mat), "plane", px, M.base + y, pz, _q, w, h, 1, color2, uv);
|
|
54120
54631
|
},
|
|
54121
54632
|
light(M, x, y, z, color2, range2, type, ex) {
|
|
54122
54633
|
const [px, pz] = loc(M, x, z);
|
|
@@ -54142,7 +54653,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
54142
54653
|
Object.assign(K, defined);
|
|
54143
54654
|
}
|
|
54144
54655
|
function installFurnitureBuilders(K, shared2) {
|
|
54145
|
-
const { PE, _q, kit2, kk, paletteColor, put, rngOf, sh } = K;
|
|
54656
|
+
const { PE, _q, kit2, kk, paletteColor, put: put2, rngOf, sh } = K;
|
|
54146
54657
|
const counterTap = (...a) => K.counterTap(...a);
|
|
54147
54658
|
const apart = () => !shared2.ctx.visorScene;
|
|
54148
54659
|
const FURNITURE = {
|
|
@@ -54194,7 +54705,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
54194
54705
|
lc("metal", -0.08, h + 0.03, -0.05, 0.01, 0.2, 9075290);
|
|
54195
54706
|
_q.identity();
|
|
54196
54707
|
const [px, pz] = [M.x + -0.08 * Math.cos(M.ry) + -0.05 * Math.sin(M.ry), M.z - -0.08 * Math.sin(M.ry) + -0.05 * Math.cos(M.ry)];
|
|
54197
|
-
|
|
54708
|
+
put2("fabric", "cone", px, M.base + h + 0.32, pz, _q, 0.36, 0.2, 0.36, 15259824);
|
|
54198
54709
|
}
|
|
54199
54710
|
},
|
|
54200
54711
|
shelf(M, A, o = {}) {
|
|
@@ -54472,7 +54983,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
54472
54983
|
lc("plain", 0, 0, 0, 0.14, 0.03, 2763306);
|
|
54473
54984
|
lc("metal", 0, 0.03, 0, 0.012, M.h - 0.35, 9075290);
|
|
54474
54985
|
_q.identity();
|
|
54475
|
-
|
|
54986
|
+
put2("fabric", "cone", M.x, M.base + (M.y || 0) + M.h - 0.2, M.z, _q, 0.4, 0.3, 0.4, 14733992);
|
|
54476
54987
|
},
|
|
54477
54988
|
microwave(M, A) {
|
|
54478
54989
|
const { b: lb } = kk(M, A);
|
|
@@ -56173,6 +56684,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
56173
56684
|
const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt, walkInSolids, kitCollides };
|
|
56174
56685
|
Object.assign(K, defined);
|
|
56175
56686
|
}
|
|
56687
|
+
var PELVIS_FROM_HEAD = 0.95;
|
|
56688
|
+
var SWING_SEAT = 0.45;
|
|
56689
|
+
var SAUNA_BENCH = 0.45;
|
|
56690
|
+
var TUB_FLOOR = 0.12;
|
|
56691
|
+
var PLAN_FURNITURE_SEATS = {
|
|
56692
|
+
sun_lounger: ({ w, d, h }) => [{ id: "lie", pose: "lie", pos: [0, h, -d / 2 + PELVIS_FROM_HEAD], ry: 0, eye: 0.2, exit: [w / 2 + 0.5, 0, 0] }],
|
|
56693
|
+
swing: ({ d }) => [{ id: "seat", pose: "sit", pos: [0, SWING_SEAT, 0], ry: 0, exit: [0, 0, d / 2 + 0.6] }],
|
|
56694
|
+
soaking_tub: ({ d }) => [{ id: "seat", pose: "sit", pos: [0, TUB_FLOOR, -d / 6], ry: 0, exit: [0, 0, d / 2 + 0.5] }],
|
|
56695
|
+
sauna: ({ d }) => [{ id: "bench", pose: "sit", pos: [0, SAUNA_BENCH, -d / 4], ry: 0, exit: [0, 0, d / 2 + 0.5] }]
|
|
56696
|
+
};
|
|
56697
|
+
var planFurnitureSeats = (type, size) => PLAN_FURNITURE_SEATS[type]?.(size) ?? [];
|
|
56176
56698
|
function installInteractionItems(K, shared2) {
|
|
56177
56699
|
const { t, LIGHTS, cursor, definePiece, localOf, registerCollision, togglePiece } = K;
|
|
56178
56700
|
const DOOR_ITEM = /^(tv_unit|tv_unit_small|tv_unit_large|sideboard|china_cabinet|filing_cabinet|pantry|laundry_cabinet|wardrobe|wardrobe_small|wardrobe_large|closet_wardrobe|kitchen_cabinet|kitchen_cabinet_large|kitchen_cabinet_small|fridge|fridge_large|display_fridge_medium|display_fridge)$/;
|
|
@@ -56192,11 +56714,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
56192
56714
|
function buildItem2(m, M, ent, api, parent) {
|
|
56193
56715
|
registerCollision(m, M);
|
|
56194
56716
|
const type = m.type;
|
|
56717
|
+
seatItem(m, M);
|
|
56195
56718
|
if (LIGHT_TYPES.has(type)) return lightItem(m, M, ent, api, parent);
|
|
56196
56719
|
if (type === "curtain") return curtainItem(m, M, ent, api, parent);
|
|
56197
56720
|
if (DOOR_ITEM.test(type) || DRAWER_ITEM.test(type)) return furnitureItem(m, M, ent, api, parent, DRAWER_ITEM.test(type));
|
|
56198
56721
|
ent.f(M, api);
|
|
56199
56722
|
}
|
|
56723
|
+
function seatItem(m, M) {
|
|
56724
|
+
const seats = planFurnitureSeats(m.type, { w: M.w, d: M.d, h: M.h });
|
|
56725
|
+
const first = seats[0];
|
|
56726
|
+
if (!first) return;
|
|
56727
|
+
const base2 = M.base + (M.y || 0), [ax, az] = localOf(M, first.pos[0], first.pos[2]);
|
|
56728
|
+
I().items.push({ type: "seat", id: m.id, floor: M.floor, anchor: [ax, base2 + first.pos[1], az], range: 1.6, angle: 1.1, pieces: [], seats, mount: { x: M.x, y: base2, z: M.z, ry: M.ry }, text: () => t(first.pose === "lie" ? "prompt.lie" : "prompt.sit"), action: () => void 0 });
|
|
56729
|
+
}
|
|
56200
56730
|
function lightItem(m, M, ent, api, parent) {
|
|
56201
56731
|
M.on = M.light = M.lit = true;
|
|
56202
56732
|
const n0 = LIGHTS.length, name = shared2.quality === "game" ? "ix:light:" + m.room + "@" + parent : "ix:light:" + m.id;
|
|
@@ -57346,7 +57876,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
57346
57876
|
PL.push(l);
|
|
57347
57877
|
}
|
|
57348
57878
|
const slotOf = (i) => lease ? lease.handles[i].slot : i;
|
|
57349
|
-
const
|
|
57879
|
+
const put2 = (i, v) => {
|
|
57350
57880
|
if (lease) {
|
|
57351
57881
|
lease.handles[i].update(v.color === void 0 || typeof v.color === "number" ? v : { ...v, color: new THREE.Color(v.color).getHex() });
|
|
57352
57882
|
return;
|
|
@@ -57485,13 +58015,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
57485
58015
|
const b0 = LZU.uRB0.value, b1 = LZU.uRB1.value, b2 = LZU.uRB2.value, by = LZU.uRBY.value, ex = LZU.uREx.value;
|
|
57486
58016
|
A.crates[i] = g ? { k: g.k, rects: g.rects, y: g.y, exterior: !!g.exterior, exclusion: g.exclusion || null, d: g.d } : null;
|
|
57487
58017
|
if (!g) {
|
|
57488
|
-
|
|
58018
|
+
put2(i, { intensity: 0 });
|
|
57489
58019
|
for (const a of [b0, b1, b2, ex]) a.set(EMPTY, at2 * 4);
|
|
57490
58020
|
by.set([0, 0], at2 * 2);
|
|
57491
58021
|
continue;
|
|
57492
58022
|
}
|
|
57493
58023
|
const lamp = g.exterior ? { intensity: g.lumens, distance: g.dist, decay: g.decay } : { intensity: (7 + g.range * 0.8) * lim(1 + 0.4 * (Math.sqrt(g.n) - 1), 1, 2.2), distance: Math.max(3, g.dm * 1.3 + 0.5), decay: 1.6 };
|
|
57494
|
-
|
|
58024
|
+
put2(i, { position: g.pos, color: g.color, ...lamp });
|
|
57495
58025
|
const rs = g.rects;
|
|
57496
58026
|
b0.set(rs[0] || EMPTY, at2 * 4);
|
|
57497
58027
|
b1.set(rs[1] || EMPTY, at2 * 4);
|
|
@@ -58031,7 +58561,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58031
58561
|
const bars = def && def.reinforcement ? pc.role === "column" || pc.role === "beam" ? { ...def.reinforcement, diameter: Math.max(def.reinforcement.diameter, MEMBER_CAGE.diameter) } : def.reinforcement : null;
|
|
58032
58562
|
const cage = bars ? pc.role === "column" && sp.shape.kind === "box" ? { ...bars, residualCapacity: cageResidualCapacity(sp.shape.size, bars, sp.structure?.capacity) } : { ...bars } : null;
|
|
58033
58563
|
const out = cage && !sp.reinforcement ? { ...sp, reinforcement: cage } : sp;
|
|
58034
|
-
if (out.reinforcement && !out.units && pc.material === "concrete" && (pc.role
|
|
58564
|
+
if (out.reinforcement && !out.units && pc.material === "concrete" && CAGED_ROLES.has(pc.role) && sp.shape.kind === "box") {
|
|
58035
58565
|
return { ...out, units: { size: [MEMBER_CAGE.unit, MEMBER_CAGE.unit, Math.min(...sp.shape.size)], bond: "stack", mortar: "concrete" } };
|
|
58036
58566
|
}
|
|
58037
58567
|
return out;
|
|
@@ -58094,6 +58624,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58094
58624
|
if (distance2 <= -depth) return true;
|
|
58095
58625
|
return distance2 <= -depth * noise3();
|
|
58096
58626
|
}
|
|
58627
|
+
var WALL_ALONG_U = { along: 0, up: 1, across: 2 };
|
|
58628
|
+
var WALL_ALONG_V = { along: 2, up: 1, across: 0 };
|
|
58629
|
+
var LYING = { along: 0, up: 2, across: 1 };
|
|
58630
|
+
function extentOf(part, axis) {
|
|
58631
|
+
if (axis === 1) return [part.y0, part.y1];
|
|
58632
|
+
return axis === 0 ? [part.aabb[0], part.aabb[2]] : [part.aabb[1], part.aabb[3]];
|
|
58633
|
+
}
|
|
58634
|
+
function planeAxesOf(part) {
|
|
58635
|
+
const [u0, v0, u1, v1] = part.aabb;
|
|
58636
|
+
if (thinAxisOf([u1 - u0, part.y1 - part.y0, v1 - v0]) === 1) return LYING;
|
|
58637
|
+
return u1 - u0 >= v1 - v0 ? WALL_ALONG_U : WALL_ALONG_V;
|
|
58638
|
+
}
|
|
58639
|
+
function pointOf2(axes, along2, up, across2) {
|
|
58640
|
+
const out = [0, 0, 0];
|
|
58641
|
+
out[axes.along] = along2;
|
|
58642
|
+
out[axes.up] = up;
|
|
58643
|
+
out[axes.across] = across2;
|
|
58644
|
+
return out;
|
|
58645
|
+
}
|
|
58097
58646
|
var JOINT_SHARE = 0.5;
|
|
58098
58647
|
var EPSILON22 = 1e-4;
|
|
58099
58648
|
function carve(boxes, grid) {
|
|
@@ -58203,11 +58752,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58203
58752
|
const boxes = part.gone?.length ? subtract(mergeSpans(part.spans), part.gone) : mergeSpans(part.spans);
|
|
58204
58753
|
for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
|
|
58205
58754
|
const along2 = line.start + (s.a + s.b) / 2;
|
|
58206
|
-
point.set(line.
|
|
58207
|
-
const
|
|
58755
|
+
point.set(...pointOf2(line.axes, along2, (s.y0 + s.y1) / 2, part.mid)).applyMatrix4(toMesh);
|
|
58756
|
+
const [hx, hy, hz] = pointOf2(line.axes, (s.b - s.a) / 2, (s.y1 - s.y0) / 2, part.thick / 2);
|
|
58208
58757
|
out.push({
|
|
58209
58758
|
center: [point.x, point.y, point.z],
|
|
58210
|
-
half: [
|
|
58759
|
+
half: [hx * scale.x, hy * scale.y, hz * scale.z],
|
|
58211
58760
|
rotation: [turn.x, turn.y, turn.z, turn.w],
|
|
58212
58761
|
kind: "box"
|
|
58213
58762
|
});
|
|
@@ -58265,6 +58814,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58265
58814
|
var SPALL_MIN = 0.025;
|
|
58266
58815
|
var SPALL_RAGGED = 0.045;
|
|
58267
58816
|
var PLASTER_REACH = { least: SPALL_MIN, band: SPALL_RAGGED };
|
|
58817
|
+
var CAST_GAP = 2e-3;
|
|
58268
58818
|
var COVER2 = 0.015;
|
|
58269
58819
|
var LUMP_BAR_INSET = 0.035;
|
|
58270
58820
|
var LUMPS_PER_BAR = 1;
|
|
@@ -58283,6 +58833,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58283
58833
|
if (hi[0] - lo[0] <= 1e-4 || hi[1] - lo[1] <= 1e-4 || hi[2] - lo[2] <= 1e-4) return null;
|
|
58284
58834
|
return { x: (lo[0] + hi[0]) / 2, y: (lo[1] + hi[1]) / 2, z: (lo[2] + hi[2]) / 2, sx: hi[0] - lo[0], sy: hi[1] - lo[1], sz: hi[2] - lo[2], colour: unit.colour };
|
|
58285
58835
|
}
|
|
58836
|
+
var axisVector = (axis) => [axis === 0 ? 1 : 0, axis === 1 ? 1 : 0, axis === 2 ? 1 : 0];
|
|
58837
|
+
function unitBoxOf(axes, centre, size, colour) {
|
|
58838
|
+
const [x, y, z] = pointOf2(axes, centre[0], centre[1], centre[2]), [sx, sy, sz] = pointOf2(axes, size[0], size[1], size[2]);
|
|
58839
|
+
return { x, y, z, sx, sy, sz, colour };
|
|
58840
|
+
}
|
|
58841
|
+
function coatedInside(bounds2, axes) {
|
|
58842
|
+
const inner = [...bounds2];
|
|
58843
|
+
inner[axes.along] = bounds2[axes.along] + COVER2;
|
|
58844
|
+
inner[axes.along + 3] = bounds2[axes.along + 3] - COVER2;
|
|
58845
|
+
inner[axes.up + 3] = bounds2[axes.up + 3] - COVER2;
|
|
58846
|
+
if (axes.up !== 1) inner[axes.up] = bounds2[axes.up] + COVER2;
|
|
58847
|
+
return inner;
|
|
58848
|
+
}
|
|
58286
58849
|
function installDestructionBreach(K, _shared) {
|
|
58287
58850
|
const { THREE, fragmentMaterial, invalidate, invalidateShadow } = K;
|
|
58288
58851
|
const paintState = { attached: false };
|
|
@@ -58451,13 +59014,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58451
59014
|
hasStrike = true;
|
|
58452
59015
|
};
|
|
58453
59016
|
function cells(part, units, mask) {
|
|
58454
|
-
const [
|
|
58455
|
-
const
|
|
58456
|
-
const
|
|
58457
|
-
const
|
|
58458
|
-
const [
|
|
58459
|
-
const rows = Math.max(1, Math.round((
|
|
58460
|
-
const rowH = (
|
|
59017
|
+
const [a0, a1] = extentOf(part, mask.axes.along), [up0, up1] = extentOf(part, mask.axes.up);
|
|
59018
|
+
const len = a1 - a0;
|
|
59019
|
+
const offset = a0 - mask.start;
|
|
59020
|
+
const merge = Math.max(1, Math.ceil(Math.sqrt(Math.max(1, Math.round((up1 - up0) / units.size[1])) * Math.max(1, Math.round(len / units.size[0])) / BREACH_GRID_CAP)));
|
|
59021
|
+
const ul = units.size[0] * merge, uh = units.size[1] * merge;
|
|
59022
|
+
const rows = Math.max(1, Math.round((up1 - up0) / uh));
|
|
59023
|
+
const rowH = (up1 - up0) / rows;
|
|
58461
59024
|
const per = Math.max(1, Math.round(len / ul));
|
|
58462
59025
|
const w = len / per;
|
|
58463
59026
|
const out = [];
|
|
@@ -58465,7 +59028,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58465
59028
|
const shift = units.bond === "running" && r & 1 ? w / 2 : 0;
|
|
58466
59029
|
for (let i = 0; i < per + (shift ? 1 : 0); i++) {
|
|
58467
59030
|
const a = Math.max(0, i * w - shift), b = Math.min(len, i * w - shift + w);
|
|
58468
|
-
if (b - a > 1e-3) out.push({ a: offset + a, b: offset + b, y0:
|
|
59031
|
+
if (b - a > 1e-3) out.push({ a: offset + a, b: offset + b, y0: up0 + r * rowH, y1: up0 + (r + 1) * rowH, r, i });
|
|
58469
59032
|
}
|
|
58470
59033
|
}
|
|
58471
59034
|
return out;
|
|
@@ -58533,8 +59096,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58533
59096
|
return [...first, ...other];
|
|
58534
59097
|
}
|
|
58535
59098
|
const pillarSpans = (view) => structure.parts.filter((q) => q.role === "column" && wallsAround(q).includes(view.host)).map((q) => {
|
|
58536
|
-
const
|
|
58537
|
-
return { a, b
|
|
59099
|
+
const [from, to] = extentOf(q, view.mask.axes.along), [y0, y1] = extentOf(q, view.mask.axes.up);
|
|
59100
|
+
return { a: from - view.mask.start, b: to - view.mask.start, y0, y1 };
|
|
58538
59101
|
});
|
|
58539
59102
|
const windowGaps = (view) => (structure.openings ?? []).filter((o) => o.kind === "window" && o.wall === view.host).map((o) => ({ a: Math.min(o.from, o.to) - view.mask.start, b: Math.max(o.from, o.to) - view.mask.start, y0: o.y0, y1: o.y1 }));
|
|
58540
59103
|
function outsideGaps(c, gaps) {
|
|
@@ -58583,9 +59146,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58583
59146
|
sh.uniforms.uToHouse = toHouse;
|
|
58584
59147
|
sh.uniforms.uMask = { value: mask.texture };
|
|
58585
59148
|
sh.uniforms.uMaskRect = { value: mask.rect };
|
|
58586
|
-
sh.uniforms.
|
|
59149
|
+
sh.uniforms.uMaskAlong = { value: axisVector(mask.axes.along) };
|
|
59150
|
+
sh.uniforms.uMaskUp = { value: axisVector(mask.axes.up) };
|
|
58587
59151
|
sh.vertexShader = sh.vertexShader.replace("void main() {", "uniform mat4 uToHouse;\nvarying vec3 vHousePos;\nvoid main() {").replace("#include <begin_vertex>", "#include <begin_vertex>\nvHousePos = (uToHouse * vec4(transformed, 1.0)).xyz;");
|
|
58588
|
-
sh.fragmentShader = sh.fragmentShader.replace("void main() {", "uniform sampler2D uMask;\nuniform vec4 uMaskRect;\nuniform
|
|
59152
|
+
sh.fragmentShader = sh.fragmentShader.replace("void main() {", "uniform sampler2D uMask;\nuniform vec4 uMaskRect;\nuniform vec3 uMaskAlong;\nuniform vec3 uMaskUp;\nvarying vec3 vHousePos;\nvoid main() {\n vec2 mUv = vec2((dot(vHousePos, uMaskAlong) - uMaskRect.x) / uMaskRect.z, (dot(vHousePos, uMaskUp) - uMaskRect.y) / uMaskRect.w);\n if (mUv.x >= 0.0 && mUv.x <= 1.0 && mUv.y >= 0.0 && mUv.y <= 1.0 && texture2D(uMask, mUv).r > 0.5) discard;");
|
|
58589
59153
|
};
|
|
58590
59154
|
material.customProgramCacheKey = () => "breachMask" + (base2.customProgramCacheKey?.() ?? "");
|
|
58591
59155
|
const mesh2 = new THREE.Mesh(g, material);
|
|
@@ -58593,7 +59157,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58593
59157
|
mesh2.userData.breachMask = mask;
|
|
58594
59158
|
mesh2.userData.cutAt = (p) => {
|
|
58595
59159
|
const v = local([p.x, p.y, p.z]);
|
|
58596
|
-
const i = Math.floor((
|
|
59160
|
+
const i = Math.floor((v[mask.axes.along] - mask.start) / mask.len * mask.w), j = Math.floor((v[mask.axes.up] - mask.y0) / mask.height * mask.h);
|
|
58597
59161
|
return i >= 0 && i < mask.w && j >= 0 && j < mask.h && mask.data[j * mask.w + i] > 127;
|
|
58598
59162
|
};
|
|
58599
59163
|
mesh2.position.copy(it.mesh.position);
|
|
@@ -58620,9 +59184,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58620
59184
|
material.onBeforeCompile = (sh) => {
|
|
58621
59185
|
sh.uniforms.uCore = { value: core.texture };
|
|
58622
59186
|
sh.uniforms.uCoreRect = { value: core.rect };
|
|
58623
|
-
sh.uniforms.
|
|
59187
|
+
sh.uniforms.uCoreAlong = { value: axisVector(core.axes.along) };
|
|
59188
|
+
sh.uniforms.uCoreUp = { value: axisVector(core.axes.up) };
|
|
58624
59189
|
sh.vertexShader = sh.vertexShader.replace("void main() {", "varying vec3 vHousePos;\nvoid main() {").replace("#include <begin_vertex>", "#include <begin_vertex>\n#ifdef USE_INSTANCING\nvHousePos = (instanceMatrix * vec4(transformed, 1.0)).xyz;\n#else\nvHousePos = transformed;\n#endif");
|
|
58625
|
-
sh.fragmentShader = sh.fragmentShader.replace("void main() {", "uniform sampler2D uCore;\nuniform vec4 uCoreRect;\nuniform
|
|
59190
|
+
sh.fragmentShader = sh.fragmentShader.replace("void main() {", "uniform sampler2D uCore;\nuniform vec4 uCoreRect;\nuniform vec3 uCoreAlong;\nuniform vec3 uCoreUp;\nvarying vec3 vHousePos;\nvoid main() {\n vec2 cUv = vec2((dot(vHousePos, uCoreAlong) - uCoreRect.x) / uCoreRect.z, (dot(vHousePos, uCoreUp) - uCoreRect.y) / uCoreRect.w);\n if (cUv.x >= 0.0 && cUv.x <= 1.0 && cUv.y >= 0.0 && cUv.y <= 1.0 && texture2D(uCore, cUv).r > 0.5) discard;").replace("#include <color_fragment>", "#include <color_fragment>\nif (!gl_FrontFacing) diffuseColor.rgb *= 0.55;");
|
|
58626
59191
|
};
|
|
58627
59192
|
material.customProgramCacheKey = () => "breachCore";
|
|
58628
59193
|
material.userData.breachCore = core;
|
|
@@ -58641,17 +59206,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58641
59206
|
}
|
|
58642
59207
|
function maskOf(hostId, parts2) {
|
|
58643
59208
|
const host = structure.byId.get(hostId);
|
|
58644
|
-
const
|
|
58645
|
-
const
|
|
58646
|
-
const y0 = Math.min(...parts2.map((id) => structure.byId.get(id).
|
|
58647
|
-
const len =
|
|
59209
|
+
const axes = planeAxesOf(host);
|
|
59210
|
+
const [start, end] = extentOf(host, axes.along);
|
|
59211
|
+
const y0 = Math.min(...parts2.map((id) => extentOf(structure.byId.get(id), axes.up)[0])), y1 = Math.max(...parts2.map((id) => extentOf(structure.byId.get(id), axes.up)[1]));
|
|
59212
|
+
const len = end - start;
|
|
58648
59213
|
const w = Math.max(2, Math.min(2048, Math.ceil(len / MASK_TEXEL))), h = Math.max(2, Math.min(1024, Math.ceil((y1 - y0) / MASK_TEXEL)));
|
|
58649
59214
|
const data = new Uint8Array(w * h);
|
|
58650
59215
|
const texture = new THREE.DataTexture(data, w, h, THREE.RedFormat);
|
|
58651
59216
|
texture.magFilter = THREE.LinearFilter;
|
|
58652
59217
|
texture.minFilter = THREE.LinearFilter;
|
|
58653
59218
|
texture.needsUpdate = true;
|
|
58654
|
-
return { data, texture, w, h,
|
|
59219
|
+
return { data, texture, w, h, axes, start, len, y0, height: y1 - y0, rect: new THREE.Vector4(start, y0, len, y1 - y0) };
|
|
58655
59220
|
}
|
|
58656
59221
|
function besidePillars(c, pillars) {
|
|
58657
59222
|
let { a, b } = c;
|
|
@@ -58680,13 +59245,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58680
59245
|
}
|
|
58681
59246
|
function splitUnits(view, id, around) {
|
|
58682
59247
|
const { mask } = view;
|
|
58683
|
-
const along2 = (p) =>
|
|
59248
|
+
const along2 = (p) => p[mask.axes.along] - mask.start;
|
|
59249
|
+
const upOf = (p) => p[mask.axes.up];
|
|
58684
59250
|
const part = structure.byId.get(id), units = specOf(id).units, chips = view.chips.get(id), opening = view.openings.get(id);
|
|
58685
59251
|
const own = cells(part, units, mask);
|
|
58686
59252
|
const all = (id === view.host ? own.flatMap((c) => besidePillars(c, around.pillars)) : own).flatMap((c) => outsideGaps(c, around.gaps));
|
|
58687
59253
|
const holes = [], kept = [];
|
|
58688
59254
|
if (view.fallen.has(id)) return { all, kept, holes: all, boxes: [] };
|
|
58689
|
-
const boxes = chips.map((k) => ({ s0: along2(k.center) - k.along, s1: along2(k.center) + k.along, y0: k.center
|
|
59255
|
+
const boxes = chips.map((k) => ({ s0: along2(k.center) - k.along, s1: along2(k.center) + k.along, y0: upOf(k.center) - k.up, y1: upOf(k.center) + k.up }));
|
|
58690
59256
|
const gone = (c) => {
|
|
58691
59257
|
const over = boxes.filter((k) => k.s1 > c.a && k.s0 < c.b && k.y1 > c.y0 && k.y0 < c.y1);
|
|
58692
59258
|
const share = covered(c, over);
|
|
@@ -58694,7 +59260,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58694
59260
|
const s = (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2;
|
|
58695
59261
|
return share >= 0.5 && over.some((k) => s >= k.s0 && s <= k.s1 && y >= k.y0 && y <= k.y1);
|
|
58696
59262
|
};
|
|
58697
|
-
const open = (c) => gone(c) || opening !== void 0 && Math.hypot((c.a + c.b) / 2 - along2(opening.center), (c.y0 + c.y1) / 2 - opening.center
|
|
59263
|
+
const open = (c) => gone(c) || opening !== void 0 && Math.hypot((c.a + c.b) / 2 - along2(opening.center), (c.y0 + c.y1) / 2 - upOf(opening.center)) < opening.radius;
|
|
58698
59264
|
for (const c of all) (open(c) ? holes : kept).push(c);
|
|
58699
59265
|
return { all, kept, holes, boxes };
|
|
58700
59266
|
}
|
|
@@ -58707,20 +59273,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58707
59273
|
function publishStanding(view) {
|
|
58708
59274
|
if (!view.saved) return;
|
|
58709
59275
|
const { mask } = view;
|
|
58710
|
-
const along2 = (p) =>
|
|
59276
|
+
const along2 = (p) => p[mask.axes.along] - mask.start;
|
|
59277
|
+
const upOf = (p) => p[mask.axes.up];
|
|
58711
59278
|
const parts2 = view.parts.map((id) => {
|
|
58712
59279
|
const part = structure.byId.get(id);
|
|
58713
|
-
const
|
|
58714
|
-
const
|
|
58715
|
-
const gone = (view.chips.get(id) ?? []).map((k) => ({ a: along2(k.center) - k.along, b: along2(k.center) + k.along, y0: k.center
|
|
59280
|
+
const [across0, across1] = extentOf(part, mask.axes.across);
|
|
59281
|
+
const thick = across1 - across0, mid = (across0 + across1) / 2;
|
|
59282
|
+
const gone = (view.chips.get(id) ?? []).map((k) => ({ a: along2(k.center) - k.along, b: along2(k.center) + k.along, y0: upOf(k.center) - k.up, y1: upOf(k.center) + k.up }));
|
|
58716
59283
|
return { spans: view.kept.get(id) ?? [], gone, thick, mid };
|
|
58717
59284
|
});
|
|
58718
|
-
const line = {
|
|
59285
|
+
const line = { axes: mask.axes, start: mask.start, open: view.core };
|
|
58719
59286
|
view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));
|
|
58720
59287
|
}
|
|
58721
59288
|
function paint(view) {
|
|
58722
59289
|
const { mask, core } = view;
|
|
58723
|
-
const along2 = (p) =>
|
|
59290
|
+
const along2 = (p) => p[mask.axes.along] - mask.start;
|
|
59291
|
+
const upOf = (p) => p[mask.axes.up];
|
|
58724
59292
|
const holes = [];
|
|
58725
59293
|
const pits = [];
|
|
58726
59294
|
const discs = [];
|
|
@@ -58736,10 +59304,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58736
59304
|
view.kept.set(id, []);
|
|
58737
59305
|
continue;
|
|
58738
59306
|
}
|
|
58739
|
-
const
|
|
58740
|
-
const
|
|
58741
|
-
if (opening) discs.push({ s: along2(opening.center), y: opening.center
|
|
58742
|
-
for (const k of spalls) flakes.push({ s: along2(k.center), y: k.center
|
|
59307
|
+
const [across0, across1] = extentOf(part, mask.axes.across);
|
|
59308
|
+
const thick = across1 - across0, mid = (across0 + across1) / 2;
|
|
59309
|
+
if (opening) discs.push({ s: along2(opening.center), y: upOf(opening.center), r: opening.radius });
|
|
59310
|
+
for (const k of spalls) flakes.push({ s: along2(k.center), y: upOf(k.center), r: k.radius });
|
|
58743
59311
|
holes.push(...lost);
|
|
58744
59312
|
view.kept.set(id, kept);
|
|
58745
59313
|
if (units2.mortar === part.material) {
|
|
@@ -58795,18 +59363,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58795
59363
|
const list2 = [];
|
|
58796
59364
|
const tone = (hex3, k) => tmp.c.setHex(hex3).multiplyScalar(k).getHex();
|
|
58797
59365
|
const b = view.bounds;
|
|
58798
|
-
const inner =
|
|
59366
|
+
const inner = coatedInside(b, mask.axes);
|
|
58799
59367
|
for (const { c, part, units: units2, thick, mid } of shown2) {
|
|
58800
59368
|
if (!near(c)) continue;
|
|
58801
59369
|
const centre = mask.start + (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2, len = c.b - c.a, h = c.y1 - c.y0;
|
|
58802
59370
|
const at2 = (s, dy, d, colour) => {
|
|
58803
|
-
const unit = clipToBox(
|
|
58804
|
-
if (unit && !discs.some((k) =>
|
|
59371
|
+
const unit = clipToBox(unitBoxOf(mask.axes, [centre, y, mid], [s, dy, d], colour), inner);
|
|
59372
|
+
if (unit && !discs.some((k) => {
|
|
59373
|
+
const p = [unit.x, unit.y, unit.z];
|
|
59374
|
+
return Math.hypot(p[mask.axes.along] - mask.start - k.s, p[mask.axes.up] - k.y) < k.r;
|
|
59375
|
+
})) list2.push(unit);
|
|
58805
59376
|
};
|
|
58806
59377
|
const base2 = fragmentMaterial(part.material).color.getHex();
|
|
58807
59378
|
const n = noise2(centre * 3.1, y * 2.7, 0.07);
|
|
58808
59379
|
if (units2.mortar === "concrete") {
|
|
58809
|
-
at2(len, h, thick - 2 * COVER2, tone(base2, 0.9 + 0.04 * n));
|
|
59380
|
+
at2(len - CAST_GAP, h - CAST_GAP, thick - 2 * COVER2, tone(base2, 0.9 + 0.04 * n));
|
|
58810
59381
|
} else {
|
|
58811
59382
|
at2(len, h, thick - 2 * COVER2 - 0.012, 10327948);
|
|
58812
59383
|
at2(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base2, 0.8 + 0.35 * n));
|
|
@@ -58835,14 +59406,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58835
59406
|
view.flakes = flakes.length;
|
|
58836
59407
|
publishStanding(view);
|
|
58837
59408
|
}
|
|
58838
|
-
function chipBox(chip,
|
|
59409
|
+
function chipBox(chip, axes) {
|
|
58839
59410
|
house.updateWorldMatrix(true, false);
|
|
58840
59411
|
const q = tmp.q.set(chip.rotation[0], chip.rotation[1], chip.rotation[2], chip.rotation[3]).premultiply(house.getWorldQuaternion(new THREE.Quaternion()).invert());
|
|
58841
59412
|
let a = 0, u = 0;
|
|
58842
59413
|
for (let k = 0; k < 3; k++) {
|
|
58843
59414
|
const axis = tmp.p.set(k === 0 ? 1 : 0, k === 1 ? 1 : 0, k === 2 ? 1 : 0).applyQuaternion(q);
|
|
58844
|
-
a += Math.abs(
|
|
58845
|
-
u += Math.abs(axis.
|
|
59415
|
+
a += Math.abs(axis.getComponent(axes.along)) * chip.size[k] / 2;
|
|
59416
|
+
u += Math.abs(axis.getComponent(axes.up)) * chip.size[k] / 2;
|
|
58846
59417
|
}
|
|
58847
59418
|
return { center: local(chip.center), along: a, up: u };
|
|
58848
59419
|
}
|
|
@@ -58878,12 +59449,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58878
59449
|
const grey = fragmentMaterial("concrete").color.getHex();
|
|
58879
59450
|
const stone = (s, y, d, size, r) => {
|
|
58880
59451
|
const centre = mask.start + s;
|
|
58881
|
-
const unit = clipToBox(
|
|
59452
|
+
const unit = clipToBox(unitBoxOf(mask.axes, [centre, y, d], size, tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(7)).getHex()), bounds2);
|
|
58882
59453
|
if (unit) out.push(unit);
|
|
58883
59454
|
};
|
|
58884
59455
|
for (const { c, part, thick, mid } of gone) {
|
|
58885
|
-
const
|
|
58886
|
-
const
|
|
59456
|
+
const [from, to] = extentOf(part, mask.axes.along), [up0, up1] = extentOf(part, mask.axes.up);
|
|
59457
|
+
const p0 = from - mask.start, p1 = to - mask.start;
|
|
59458
|
+
const lying = p1 - p0 > up1 - up0;
|
|
58887
59459
|
const random = (seed) => (n) => {
|
|
58888
59460
|
const x = Math.sin(seed + n * 3.3) * 43758.5453;
|
|
58889
59461
|
return x - Math.floor(x);
|
|
@@ -58901,7 +59473,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58901
59473
|
stone(s, y, d, [size, size * (0.6 + 0.5 * r(4)), size], r);
|
|
58902
59474
|
}
|
|
58903
59475
|
}
|
|
58904
|
-
const bars = lying ? [
|
|
59476
|
+
const bars = lying ? [up0 + LUMP_BAR_INSET, up1 - LUMP_BAR_INSET].filter((y) => y >= c.y0 - 1e-6 && y <= c.y1 + 1e-6) : [p0 + LUMP_BAR_INSET, p1 - LUMP_BAR_INSET].filter((s) => s >= c.a - 1e-6 && s <= c.b + 1e-6);
|
|
58905
59477
|
for (const bar2 of bars) {
|
|
58906
59478
|
for (const side of [-1, 1]) {
|
|
58907
59479
|
const d = mid + side * (thick / 2 - LUMP_BAR_INSET);
|
|
@@ -58961,8 +59533,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
58961
59533
|
if (view.openings.has(partId)) return false;
|
|
58962
59534
|
view.openings.set(partId, { center: local(change.opening.center), radius: change.opening.radius });
|
|
58963
59535
|
}
|
|
58964
|
-
if (change.chip) view.chips.get(partId).push(chipBox(change.chip, view.mask.
|
|
58965
|
-
for (const chip of change.chips ?? []) view.chips.get(partId).push(chipBox(chip, view.mask.
|
|
59536
|
+
if (change.chip) view.chips.get(partId).push(chipBox(change.chip, view.mask.axes));
|
|
59537
|
+
for (const chip of change.chips ?? []) view.chips.get(partId).push(chipBox(chip, view.mask.axes));
|
|
58966
59538
|
if (change.spall) {
|
|
58967
59539
|
const list2 = view.spalls.get(partId);
|
|
58968
59540
|
list2.push({ center: local(change.spall.center), radius: change.spall.radius });
|
|
@@ -59063,13 +59635,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
59063
59635
|
},
|
|
59064
59636
|
/**
|
|
59065
59637
|
* What still stands of the units of `partId` once its wall is cut, as drawn: spans along the wall from `start` (in the house's space, along u when
|
|
59066
|
-
* `
|
|
59638
|
+
* `axes.along`) and up `axes.up`. Null while the wall is whole (all of the part stands).
|
|
59067
59639
|
*/
|
|
59068
59640
|
standing(partId) {
|
|
59069
59641
|
const hostId = hostOf(partId), view = hostId ? views.get(hostId) : void 0;
|
|
59070
59642
|
if (view?.keptStale) refreshKept(view);
|
|
59071
59643
|
const spans = view?.saved ? view.kept.get(partId) : void 0;
|
|
59072
|
-
return view && spans ? { spans,
|
|
59644
|
+
return view && spans ? { spans, axes: view.mask.axes, start: view.mask.start } : null;
|
|
59073
59645
|
},
|
|
59074
59646
|
/** Handles a `stage` event of the house's object. Returns true when the wall was cut. */
|
|
59075
59647
|
stage(event) {
|
|
@@ -59524,8 +60096,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
59524
60096
|
if (du * du + dv * dv >= radius * radius) continue;
|
|
59525
60097
|
const left = breach.standing(part.id);
|
|
59526
60098
|
if (!left) return true;
|
|
59527
|
-
const s0 = (left.
|
|
59528
|
-
const
|
|
60099
|
+
const s0 = (left.axes.along === 0 ? lx : lz) - left.start;
|
|
60100
|
+
const flat = left.axes.up !== 1, t0 = left.axes.up === 0 ? lx : lz;
|
|
60101
|
+
const low1 = flat ? t0 - radius : Math.min(ly0, ly1), high1 = flat ? t0 + radius : Math.max(ly0, ly1);
|
|
59529
60102
|
for (const c of left.spans) if (c.b > s0 - radius && c.a < s0 + radius && c.y1 > low1 && c.y0 < high1) return true;
|
|
59530
60103
|
}
|
|
59531
60104
|
return false;
|
|
@@ -61782,18 +62355,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
61782
62355
|
};
|
|
61783
62356
|
return { spec, build, top, fixed };
|
|
61784
62357
|
}
|
|
62358
|
+
var furnitureCatalogEntry = (type, catalog) => (catalog ?? residentialItems).find((i) => i.type === type);
|
|
61785
62359
|
function furnitureSpec(THREE, type, opts = {}) {
|
|
61786
62360
|
const renderer = rendererOf(THREE, opts.document);
|
|
61787
62361
|
const ent = renderer.types[type];
|
|
61788
62362
|
if (!ent) throw new Error(`game-floorplan-three: no builder for the furniture type "${type}"`);
|
|
61789
|
-
const entry2 = (opts.catalog
|
|
62363
|
+
const entry2 = furnitureCatalogEntry(type, opts.catalog);
|
|
61790
62364
|
const w = opts.w ?? entry2?.w;
|
|
61791
62365
|
const d = opts.d ?? entry2?.d;
|
|
61792
62366
|
const h = opts.h ?? entry2?.h;
|
|
61793
62367
|
if (w === void 0 || d === void 0 || h === void 0) throw new Error(`game-floorplan-three: furniture type "${type}" is not in the catalogue, so give w, d and h`);
|
|
61794
62368
|
const o = opts.options ?? {};
|
|
61795
62369
|
const seed = Math.round(opts.seed ?? 1);
|
|
61796
|
-
const plain2 = SHELVING.test(type) ? "paper" : "plastic";
|
|
62370
|
+
const plain2 = entry2?.material ?? (SHELVING.test(type) ? "paper" : "plastic");
|
|
61797
62371
|
const root = { x: seed, z: 0, ry: 0, w, d, h, y: 0, base: 0, palette: o.palette, seed: `furniture_${type}_${seed}` };
|
|
61798
62372
|
const { K, shared: shared2 } = renderer.internals;
|
|
61799
62373
|
const before = K.PARTS.length;
|