@adatechnology/game-items-three 0.11.2 → 0.11.4

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.
@@ -13125,33 +13125,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13125
13125
  return out;
13126
13126
  };
13127
13127
  var granules = (inp, box4, count) => bsp(box4, count, [0, 1, 2], inp.rnd).map((b) => ({ center: b.c, size: b.s, q: quat.identity(), shape: "chunk", weight: b.s[0] * b.s[1] * b.s[2] }));
13128
- var SLAB_MIN = 0.03;
13129
- var splitAtHit = (root, hit, axes, count, rnd) => {
13130
- let pieces = [root];
13131
- for (const ax of axes) {
13132
- const half = root.s[ax] / 2;
13133
- if (hit[ax] - -half < SLAB_MIN || half - hit[ax] < SLAB_MIN) continue;
13134
- const next = [];
13135
- for (const b of pieces) {
13136
- const lo = b.c[ax] - b.s[ax] / 2;
13137
- const hi = b.c[ax] + b.s[ax] / 2;
13138
- for (const [from, to] of [[lo, hit[ax]], [hit[ax], hi]]) {
13139
- const c = [b.c[0], b.c[1], b.c[2]];
13140
- const s = [b.s[0], b.s[1], b.s[2]];
13141
- c[ax] = (from + to) / 2;
13142
- s[ax] = to - from;
13143
- next.push({ c, s });
13144
- }
13145
- }
13146
- pieces = next;
13147
- }
13148
- while (pieces.length < count) {
13149
- pieces.sort((a, b) => b.s[axes[0]] * b.s[axes[1]] - a.s[axes[0]] * a.s[axes[1]]);
13150
- const [big, ...rest2] = pieces;
13151
- pieces = [...bsp(big, 2, axes, rnd), ...rest2];
13152
- }
13153
- return pieces;
13154
- };
13155
13128
  var CRUMBS = 6;
13156
13129
  var severAt = (inp, root, at2, gap) => {
13157
13130
  const dims = root.s;
@@ -13199,8 +13172,72 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13199
13172
  }
13200
13173
  return out;
13201
13174
  };
13175
+ var radialPlates = (inp, root, axes, n, th, cap, fit = false) => {
13176
+ const { rnd, maxFragments } = inp;
13177
+ const { t, u, v } = axes;
13178
+ const dims = root.s;
13179
+ const out = [];
13180
+ const Hu = dims[u] / 2, Hv = dims[v] / 2;
13181
+ const hu = clamp(inp.hit[u] - root.c[u], -Hu * 0.95, Hu * 0.95);
13182
+ const hv = clamp(inp.hit[v] - root.c[v], -Hv * 0.95, Hv * 0.95);
13183
+ const R = Math.max(Math.hypot(Hu + Math.abs(hu), Hv + Math.abs(hv)), 0.02);
13184
+ const sectors = clamp(Math.round(Math.sqrt(n * 1.6)), Math.min(5, n), 10);
13185
+ const rings = Math.max(1, Math.ceil(n / sectors));
13186
+ const radii = [];
13187
+ for (let k = 0; k <= rings; k++) radii.push(R * Math.pow(k / rings, 1.3));
13188
+ for (let j = 0; j < sectors && out.length < maxFragments; j++) {
13189
+ const theta = (j + (rnd() - 0.5) * 0.4) * (Math.PI * 2 / sectors);
13190
+ for (let k = 0; k < rings && out.length < maxFragments; k++) {
13191
+ const rm = (radii[k] + radii[k + 1]) / 2;
13192
+ const cu = hu + rm * Math.cos(theta);
13193
+ const cv = hv + rm * Math.sin(theta);
13194
+ if (Math.abs(cu) > Hu + 0.01 || Math.abs(cv) > Hv + 0.01) continue;
13195
+ const radial = clamp(radii[k + 1] - radii[k], 0.01, cap);
13196
+ const tang = clamp(radii[k + 1] * (Math.PI * 2 / sectors) * 0.9, 0.01, cap);
13197
+ const c = [root.c[0], root.c[1], root.c[2]];
13198
+ c[u] = root.c[u] + clamp(cu, -Hu * 0.98, Hu * 0.98);
13199
+ c[v] = root.c[v] + clamp(cv, -Hv * 0.98, Hv * 0.98);
13200
+ const shrink = fit ? fitInside(radial, tang, theta, Hu, Hv) : 1;
13201
+ if (fit) {
13202
+ const reach2 = reachOf(radial * shrink, tang * shrink, theta);
13203
+ c[u] = root.c[u] + clamp(c[u] - root.c[u], -(Hu - reach2[0]), Hu - reach2[0]);
13204
+ c[v] = root.c[v] + clamp(c[v] - root.c[v], -(Hv - reach2[1]), Hv - reach2[1]);
13205
+ }
13206
+ out.push({ center: c, size: [radial * shrink, tang * shrink, th], q: frame(u, v, t, theta), shape: "shard", weight: radial * tang * shrink * shrink });
13207
+ }
13208
+ }
13209
+ if (out.length === 0) out.push({ center: [root.c[0], root.c[1], root.c[2]], size: [dims[u], dims[v], th], q: frame(u, v, t), shape: "shard", weight: 1 });
13210
+ return out;
13211
+ };
13212
+ var reachOf = (radial, tang, theta) => {
13213
+ const cos = Math.abs(Math.cos(theta)), sin = Math.abs(Math.sin(theta));
13214
+ return [(cos * radial + sin * tang) / 2, (sin * radial + cos * tang) / 2];
13215
+ };
13216
+ var fitInside = (radial, tang, theta, halfU, halfV) => {
13217
+ const [reachU, reachV] = reachOf(radial, tang, theta);
13218
+ return Math.min(halfU / Math.max(reachU, 1e-9), halfV / Math.max(reachV, 1e-9), 1);
13219
+ };
13202
13220
  var STACK_LAYER = 0.012;
13221
+ var SOLID_VOLUME_MIN = 1e-6;
13203
13222
  var planFragments = (inp) => {
13223
+ const solids = inp.solids;
13224
+ if (!solids || solids.length < 2) return planBox(inp);
13225
+ const volumes = solids.map((solid) => Math.max(SOLID_VOLUME_MIN, solid.size[0] * solid.size[1] * solid.size[2]));
13226
+ const total = volumes.reduce((sum, volume) => sum + volume, 0);
13227
+ const out = [];
13228
+ solids.forEach((solid, i) => {
13229
+ const share = Math.max(1, Math.round(inp.maxFragments * volumes[i] / total));
13230
+ const hit = [inp.hit[0] - solid.center[0], inp.hit[1] - solid.center[1], inp.hit[2] - solid.center[2]];
13231
+ const { cut, solids: _all, ...rest2 } = inp;
13232
+ const along2 = cut ? [0, 1, 2].sort((a, b) => solid.size[b] - solid.size[a])[0] : -1;
13233
+ const inside3 = cut && Math.abs(cut.at - solid.center[along2]) < solid.size[along2] / 2 ? { cut: { at: cut.at - solid.center[along2], gap: cut.gap } } : {};
13234
+ for (const f of planBox({ ...rest2, ...inside3, dims: [solid.size[0], solid.size[1], solid.size[2]], hit, maxFragments: share, thickness: Math.min(inp.thickness, Math.min(...solid.size)) })) {
13235
+ out.push({ ...f, center: [f.center[0] + solid.center[0], f.center[1] + solid.center[1], f.center[2] + solid.center[2]] });
13236
+ }
13237
+ });
13238
+ return out;
13239
+ };
13240
+ var planBox = (inp) => {
13204
13241
  const { style, dims, rnd, maxFragments } = inp;
13205
13242
  const [fmin, fmax] = inp.fragmentSize;
13206
13243
  const mean = (fmin + fmax) / 2;
@@ -13213,9 +13250,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13213
13250
  if (style === "snap") {
13214
13251
  if (inp.cut) return severAt(inp, root, inp.cut.at, inp.cut.gap);
13215
13252
  if (inp.form === "plies") return plyBreak(inp, root, maxFragments);
13216
- const n2 = Math.min(maxFragments, 2 + Math.floor(rnd() * 3));
13217
- const slabs = inp.form === "granules" && dims[t] < Math.min(dims[u], dims[v]) / 4 ? splitAtHit(root, inp.hit, [u, v], n2, rnd) : bsp(root, n2, [0, 1, 2], rnd);
13218
- for (const b of slabs) out.push({ center: b.c, size: b.s, q: idq, shape: "slab", weight: b.s[0] * b.s[1] * b.s[2] });
13253
+ const thinBoard = dims[t] < Math.min(dims[u], dims[v]) / 4;
13254
+ if (thinBoard && inp.form !== "slivers") {
13255
+ const crumbled = inp.form === "granules" ? CRUMBS : 0;
13256
+ const plates = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 6, Math.max(6, maxFragments - crumbled));
13257
+ for (const f of radialPlates(inp, root, { t, u, v }, plates, dims[t], fmax * 1.5, true)) out.push({ ...f, weight: f.size[0] * f.size[1] * dims[t] });
13258
+ } else {
13259
+ const n2 = Math.min(maxFragments, 2 + Math.floor(rnd() * 3));
13260
+ for (const b of bsp(root, n2, [0, 1, 2], rnd)) out.push({ center: b.c, size: b.s, q: idq, shape: "slab", weight: b.s[0] * b.s[1] * b.s[2] });
13261
+ }
13219
13262
  if (inp.form !== "granules") return out;
13220
13263
  const crumbs = Math.min(CRUMBS, maxFragments - out.length);
13221
13264
  if (crumbs <= 0) return out;
@@ -13238,44 +13281,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13238
13281
  return out;
13239
13282
  }
13240
13283
  if (style === "tear") {
13284
+ if (inp.form === "granules") return granules(inp, root, clamp(Math.ceil(dims[0] * dims[1] * dims[2] / (mean * mean * mean)), 3, maxFragments));
13241
13285
  const n2 = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 3, maxFragments);
13242
13286
  const sheet = inp.sheet ?? 0;
13243
13287
  if (sheet > 0 && dims[t] > sheet * 4) return tearStack(inp, root, t, u, v, n2, sheet);
13244
- const th2 = Math.min(inp.thickness, dims[t]);
13288
+ const th = Math.min(inp.thickness, dims[t]);
13245
13289
  for (const b of bsp(root, n2, [u, v], rnd)) {
13246
- out.push({ center: [b.c[0], b.c[1], b.c[2]], size: [b.s[u], b.s[v], th2], q: frame(u, v, t), shape: "scrap", weight: b.s[u] * b.s[v] });
13290
+ out.push({ center: [b.c[0], b.c[1], b.c[2]], size: [b.s[u], b.s[v], th], q: frame(u, v, t), shape: "scrap", weight: b.s[u] * b.s[v] });
13247
13291
  }
13248
13292
  return out;
13249
13293
  }
13250
- const th = Math.min(inp.thickness, dims[t]);
13251
- const Hu = dims[u] / 2, Hv = dims[v] / 2;
13252
- const hu = clamp(inp.hit[u], -Hu * 0.95, Hu * 0.95);
13253
- const hv = clamp(inp.hit[v], -Hv * 0.95, Hv * 0.95);
13254
- const R = Math.max(Math.hypot(Hu + Math.abs(hu), Hv + Math.abs(hv)), 0.02);
13255
13294
  const n = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 6, maxFragments);
13256
- const sectors = clamp(Math.round(Math.sqrt(n * 1.6)), 5, 10);
13257
- const rings = Math.max(1, Math.ceil(n / sectors));
13258
- const radii = [];
13259
- for (let k = 0; k <= rings; k++) radii.push(R * Math.pow(k / rings, 1.3));
13260
- const cap = fmax * 1.5;
13261
- for (let j = 0; j < sectors && out.length < maxFragments; j++) {
13262
- const theta = (j + (rnd() - 0.5) * 0.4) * (Math.PI * 2 / sectors);
13263
- for (let k = 0; k < rings && out.length < maxFragments; k++) {
13264
- const rm = (radii[k] + radii[k + 1]) / 2;
13265
- const cu = hu + rm * Math.cos(theta);
13266
- const cv = hv + rm * Math.sin(theta);
13267
- if (Math.abs(cu) > Hu + 0.01 || Math.abs(cv) > Hv + 0.01) continue;
13268
- const radial = clamp(radii[k + 1] - radii[k], 0.01, cap);
13269
- const tang = clamp(radii[k + 1] * (Math.PI * 2 / sectors) * 0.9, 0.01, cap);
13270
- const c = [0, 0, 0];
13271
- c[u] = clamp(cu, -Hu * 0.98, Hu * 0.98);
13272
- c[v] = clamp(cv, -Hv * 0.98, Hv * 0.98);
13273
- c[t] = 0;
13274
- out.push({ center: c, size: [radial, tang, th], q: frame(u, v, t, theta), shape: "shard", weight: radial * tang });
13275
- }
13276
- }
13277
- if (out.length === 0) out.push({ center: [0, 0, 0], size: [dims[u], dims[v], th], q: frame(u, v, t), shape: "shard", weight: 1 });
13278
- return out;
13295
+ return radialPlates(inp, root, { t, u, v }, n, Math.min(inp.thickness, dims[t]), fmax * 1.5);
13279
13296
  };
13280
13297
  var planeAxes = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
13281
13298
  var unitGrid = (dims, thin, units, cap) => {
@@ -15380,6 +15397,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15380
15397
  penetration: 0.5,
15381
15398
  ductility: 0.7,
15382
15399
  fracture: "tear",
15400
+ splitForm: "granules",
15383
15401
  fragmentSize: [
15384
15402
  0.03,
15385
15403
  0.15
@@ -19664,7 +19682,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19664
19682
  rnd: planRnd,
19665
19683
  sheet: p.mat.sheet,
19666
19684
  ...p.mat.splitForm ? { form: p.mat.splitForm } : {},
19667
- ...cutAt2 !== void 0 ? { cut: { at: cutAt2, gap: SEVER_BAND } } : {}
19685
+ ...cutAt2 !== void 0 ? { cut: { at: cutAt2, gap: SEVER_BAND } } : {},
19686
+ ...p.spec.solids ? { solids: p.spec.solids } : {}
19668
19687
  });
19669
19688
  const holes = p.st.holes.length > 0 ? localHolesOf(p) : [];
19670
19689
  const mass = p.st.mass;
@@ -43116,6 +43135,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43116
43135
  var bin = { body: { material: "plastic", joint: "fused" }, parts: [["lid", door("plastic", "hinge", "lid")]] };
43117
43136
  var upholstery = { material: "fabric", joint: "glue" };
43118
43137
  var POLE_CAGE = { material: "steel", spacing: 0.1, diameter: 0.01 };
43138
+ var BRICKWORK = { size: [0.23, 0.075, 0.11], bond: "running", mortar: "mortar" };
43119
43139
  var DESTRUCTION = {
43120
43140
  fridge: fridgeLike,
43121
43141
  fridge_compact: fridgeLike,
@@ -43171,13 +43191,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43171
43191
  parts: [["flap", door("steel", "hinge", "flap")], ["flag", { material: "steel", joint: "hinge", piece: "flag" }]]
43172
43192
  },
43173
43193
  dog_house: { body: { material: "plywood", joint: "nail" }, parts: [] },
43174
- bbq: { body: { material: "brick", joint: "mortar" }, parts: [["counter_door", door("steel")]] },
43194
+ bbq: { body: { material: "brick", joint: "mortar", units: BRICKWORK }, parts: [["counter_door", door("steel")]] },
43175
43195
  bunk_bed: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
43176
43196
  wood_stove: {
43177
43197
  body: { material: "cast_iron", joint: "bolt" },
43178
43198
  parts: [["firebox_door", { material: "cast_iron", joint: "hinge", piece: "door" }]]
43179
43199
  },
43180
- fireplace: { body: { material: "brick", joint: "mortar" }, parts: [] },
43200
+ fireplace: { body: { material: "brick", joint: "mortar", units: BRICKWORK }, parts: [] },
43181
43201
  outhouse: {
43182
43202
  body: { material: "wood_soft", joint: "nail" },
43183
43203
  parts: [["door", door("wood_soft", "hinge", "door")], ["seat_lid", door("wood_soft", "hinge", "lid")]]
@@ -43291,6 +43311,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43291
43311
  "prompt.glass_door.open": "Close the glass door",
43292
43312
  "prompt.glass_door.closed": "Open the glass door",
43293
43313
  "prompt.flush": "Flush",
43314
+ "prompt.flush.off": "Flush",
43315
+ "prompt.flush.on": "Flushing",
43316
+ "program.wash": "Wash",
43317
+ "program.dry": "Spin-dry",
43318
+ "use.grill": "Put {item} on the grill",
43294
43319
  "prompt.toilet_lid": "Toilet lid",
43295
43320
  "prompt.toilet_lid.open": "Close the lid",
43296
43321
  "prompt.toilet_lid.closed": "Lift the lid",
@@ -43534,6 +43559,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43534
43559
  "prompt.glass_door.open": "Fechar a porta de vidro",
43535
43560
  "prompt.glass_door.closed": "Abrir a porta de vidro",
43536
43561
  "prompt.flush": "Descarga",
43562
+ "prompt.flush.off": "Dar a descarga",
43563
+ "prompt.flush.on": "Descarga correndo",
43564
+ "program.wash": "Lavar",
43565
+ "program.dry": "Secar",
43566
+ "use.grill": "P\xF4r {item} na grelha",
43537
43567
  "prompt.toilet_lid": "Tampa do vaso",
43538
43568
  "prompt.toilet_lid.open": "Fechar a tampa",
43539
43569
  "prompt.toilet_lid.closed": "Levantar a tampa",
@@ -44161,7 +44191,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44161
44191
  h: 1.3,
44162
44192
  y: 0,
44163
44193
  solid: true,
44164
- massKg: 6
44194
+ massKg: 6,
44195
+ fixed: true
44165
44196
  },
44166
44197
  {
44167
44198
  id: "dog_house",