@adatechnology/game-weapons-three 0.8.0 → 0.9.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/README.md +2 -0
- package/dist/index.d.ts +21 -2
- package/dist/index.global.js +43658 -24883
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +116 -27
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/area.ts
|
|
2
|
+
import { markKitOrigin as markKitOrigin4 } from "@adatechnology/game-contracts";
|
|
2
3
|
import { createArsenal } from "@adatechnology/game-weapons";
|
|
4
|
+
import { furnitureSpec } from "@adatechnology/game-floorplan-three";
|
|
3
5
|
|
|
4
6
|
// src/attachments-key.ts
|
|
5
7
|
var attachmentsKey = (parts) => {
|
|
@@ -1646,9 +1648,12 @@ function holdOfProp(THREE, group, category, scale) {
|
|
|
1646
1648
|
}
|
|
1647
1649
|
|
|
1648
1650
|
// src/props.ts
|
|
1651
|
+
import { markKitOrigin as markKitOrigin2 } from "@adatechnology/game-contracts";
|
|
1652
|
+
import { buildItem, hasItemModel } from "@adatechnology/game-items-three";
|
|
1649
1653
|
import { mergeByMaterial, shapeGeometries as shapeGeometries2 } from "@adatechnology/game-shapes-three";
|
|
1650
1654
|
|
|
1651
1655
|
// src/models/index.ts
|
|
1656
|
+
import { markKitOrigin } from "@adatechnology/game-contracts";
|
|
1652
1657
|
import { WEAPONS } from "@adatechnology/game-weapons";
|
|
1653
1658
|
|
|
1654
1659
|
// src/data/models.json
|
|
@@ -4727,6 +4732,7 @@ function buildWeaponModelById(THREE, id) {
|
|
|
4727
4732
|
built.group.position.x = -new THREE.Box3().setFromObject(built.group).min.x;
|
|
4728
4733
|
} else root = fitLength(kit, built.group, entry.length / 1e3);
|
|
4729
4734
|
root.name = id;
|
|
4735
|
+
markKitOrigin(root, { owner: "game-weapons-three", kind: "weapon", id });
|
|
4730
4736
|
const model = { id, root, inner: built.group, parts: built.parts };
|
|
4731
4737
|
if (!built.parts.frames) built.parts.frames = deriveFrames(THREE, model);
|
|
4732
4738
|
return model;
|
|
@@ -4815,15 +4821,90 @@ function buildProp(THREE, prop) {
|
|
|
4815
4821
|
}
|
|
4816
4822
|
return group;
|
|
4817
4823
|
}
|
|
4824
|
+
var WEAPON_ITEM_MODELS = /* @__PURE__ */ new Map([
|
|
4825
|
+
["wrench", { item: "adjustable_wrench" }],
|
|
4826
|
+
["extinguisher", { item: "fire_extinguisher", flip: true }],
|
|
4827
|
+
["blowtorch", { item: "gas_torch", flip: true }],
|
|
4828
|
+
["crossbow", { turn: 1 }],
|
|
4829
|
+
["knife", { flip: true }],
|
|
4830
|
+
["meat_cleaver", { flip: true }],
|
|
4831
|
+
["screwdriver", { flip: true }]
|
|
4832
|
+
]);
|
|
4833
|
+
function registerWeaponItemModel(weaponId, model) {
|
|
4834
|
+
WEAPON_ITEM_MODELS.set(weaponId, model ?? { item: "" });
|
|
4835
|
+
}
|
|
4836
|
+
function itemModelOfWeapon(weaponId) {
|
|
4837
|
+
const id = WEAPON_ITEM_MODELS.get(weaponId)?.item ?? weaponId;
|
|
4838
|
+
return id && hasItemModel(id) ? id : void 0;
|
|
4839
|
+
}
|
|
4840
|
+
function buildItemWeaponModel(THREE, def) {
|
|
4841
|
+
const itemId = itemModelOfWeapon(def.id);
|
|
4842
|
+
if (!itemId) return void 0;
|
|
4843
|
+
const { root } = buildItem(THREE, { id: itemId, category: "weapon", size: [0, 0, 0], model: itemId });
|
|
4844
|
+
const group = markKitOrigin2(new THREE.Group(), { owner: "game-weapons-three", kind: "weapon", id: def.id });
|
|
4845
|
+
group.name = def.id;
|
|
4846
|
+
group.add(root);
|
|
4847
|
+
const sizeOf = () => {
|
|
4848
|
+
group.updateMatrixWorld(true);
|
|
4849
|
+
return new THREE.Box3().setFromObject(root).getSize(new THREE.Vector3());
|
|
4850
|
+
};
|
|
4851
|
+
let size = sizeOf();
|
|
4852
|
+
if (size.y > size.x && size.y >= size.z) root.rotateOnWorldAxis(new THREE.Vector3(0, 0, 1), -Math.PI / 2);
|
|
4853
|
+
else if (size.z > size.x && size.z > size.y) root.rotateOnWorldAxis(new THREE.Vector3(0, 1, 0), Math.PI / 2);
|
|
4854
|
+
size = sizeOf();
|
|
4855
|
+
if (size.z < size.y) root.rotateOnWorldAxis(new THREE.Vector3(1, 0, 0), Math.PI / 2);
|
|
4856
|
+
const turn2 = WEAPON_ITEM_MODELS.get(def.id)?.turn ?? 0;
|
|
4857
|
+
if (turn2) root.rotateOnWorldAxis(new THREE.Vector3(0, 1, 0), turn2 * Math.PI / 2);
|
|
4858
|
+
const box2 = new THREE.Box3().setFromObject(root);
|
|
4859
|
+
const middle = (box2.min.x + box2.max.x) / 2;
|
|
4860
|
+
const span = [
|
|
4861
|
+
[Infinity, -Infinity],
|
|
4862
|
+
[Infinity, -Infinity]
|
|
4863
|
+
];
|
|
4864
|
+
const point = new THREE.Vector3();
|
|
4865
|
+
root.traverse((node) => {
|
|
4866
|
+
const mesh = node;
|
|
4867
|
+
const position = mesh.isMesh ? mesh.geometry.getAttribute("position") : void 0;
|
|
4868
|
+
if (!position) return;
|
|
4869
|
+
for (let i = 0; i < position.count; i++) {
|
|
4870
|
+
point.fromBufferAttribute(position, i).applyMatrix4(mesh.matrixWorld);
|
|
4871
|
+
const half = span[point.x > middle ? 1 : 0];
|
|
4872
|
+
half[0] = Math.min(half[0], point.z);
|
|
4873
|
+
half[1] = Math.max(half[1], point.z);
|
|
4874
|
+
}
|
|
4875
|
+
});
|
|
4876
|
+
const reach = span.map(([low, high]) => high - low);
|
|
4877
|
+
const flip = WEAPON_ITEM_MODELS.get(def.id)?.flip === true;
|
|
4878
|
+
if (reach[0] > reach[1] !== flip) root.rotateOnWorldAxis(new THREE.Vector3(0, 1, 0), Math.PI);
|
|
4879
|
+
group.updateMatrixWorld(true);
|
|
4880
|
+
const laid = new THREE.Box3().setFromObject(root);
|
|
4881
|
+
const centre = laid.getCenter(new THREE.Vector3());
|
|
4882
|
+
root.position.sub(new THREE.Vector3(centre.x, laid.min.y, centre.z));
|
|
4883
|
+
const length = laid.max.x - laid.min.x;
|
|
4884
|
+
const handle = new THREE.Object3D();
|
|
4885
|
+
handle.name = "handle";
|
|
4886
|
+
handle.position.set(-length * 0.35, 0, 0);
|
|
4887
|
+
group.add(handle);
|
|
4888
|
+
root.traverse((node) => {
|
|
4889
|
+
const mesh = node;
|
|
4890
|
+
if (!mesh.isMesh) return;
|
|
4891
|
+
mesh.castShadow = true;
|
|
4892
|
+
mesh.receiveShadow = true;
|
|
4893
|
+
});
|
|
4894
|
+
return group;
|
|
4895
|
+
}
|
|
4818
4896
|
function buildWeaponModel(THREE, def) {
|
|
4819
|
-
return buildProp(THREE, weaponProp(def));
|
|
4897
|
+
return buildItemWeaponModel(THREE, def) ?? buildProp(THREE, weaponProp(def));
|
|
4820
4898
|
}
|
|
4821
4899
|
var MODEL_BODY = "body";
|
|
4822
4900
|
function buildModeledProp(THREE, def, name, decorate) {
|
|
4823
|
-
const model = buildWeaponModelById(THREE, def.id)
|
|
4901
|
+
const model = buildWeaponModelById(THREE, def.id) ?? (() => {
|
|
4902
|
+
const root = buildItemWeaponModel(THREE, def);
|
|
4903
|
+
return root ? { root } : void 0;
|
|
4904
|
+
})();
|
|
4824
4905
|
if (!model) return void 0;
|
|
4825
4906
|
decorate?.(model.root);
|
|
4826
|
-
const group = new THREE.Group();
|
|
4907
|
+
const group = markKitOrigin2(new THREE.Group(), { owner: "game-weapons-three", kind: "weapon", id: def.id });
|
|
4827
4908
|
group.name = name;
|
|
4828
4909
|
const box2 = new THREE.Box3().setFromObject(model.root);
|
|
4829
4910
|
const center = box2.getCenter(new THREE.Vector3());
|
|
@@ -5994,6 +6075,7 @@ function applyCondition(kit, model, condition) {
|
|
|
5994
6075
|
}
|
|
5995
6076
|
|
|
5996
6077
|
// src/models/cartridge.ts
|
|
6078
|
+
import { markKitOrigin as markKitOrigin3 } from "@adatechnology/game-contracts";
|
|
5997
6079
|
var BOTTLENECK_RATIO = 0.8;
|
|
5998
6080
|
function cartridgeShape(caliber, dims) {
|
|
5999
6081
|
if (caliber.caseType === "shell" || caliber.rim === "shell") return "shell";
|
|
@@ -6005,7 +6087,7 @@ function cartridgeShape(caliber, dims) {
|
|
|
6005
6087
|
}
|
|
6006
6088
|
function buildCartridge(kit, dims, shape) {
|
|
6007
6089
|
const { M, cylinderY } = kit;
|
|
6008
|
-
const group = kit.group();
|
|
6090
|
+
const group = markKitOrigin3(kit.group(), { owner: "game-weapons-three", kind: "ammunition", id: shape });
|
|
6009
6091
|
const radius = dims.caseDiameter / 2;
|
|
6010
6092
|
const bulletRadius = dims.projectileDiameter / 2;
|
|
6011
6093
|
const caseLength = dims.caseLength;
|
|
@@ -6037,7 +6119,7 @@ function buildCartridge(kit, dims, shape) {
|
|
|
6037
6119
|
}
|
|
6038
6120
|
function buildCasing(kit, dims, shape) {
|
|
6039
6121
|
const { M, cylinderX } = kit;
|
|
6040
|
-
const group = kit.group();
|
|
6122
|
+
const group = markKitOrigin3(kit.group(), { owner: "game-weapons-three", kind: "ammunition", id: shape });
|
|
6041
6123
|
const radius = dims.caseDiameter / 2e3;
|
|
6042
6124
|
const length = dims.caseLength / 1e3;
|
|
6043
6125
|
if (shape === "shell") {
|
|
@@ -6053,7 +6135,7 @@ function buildCasing(kit, dims, shape) {
|
|
|
6053
6135
|
return { group, radius, length };
|
|
6054
6136
|
}
|
|
6055
6137
|
function buildRound(kit, dims, shape) {
|
|
6056
|
-
const group = kit.group();
|
|
6138
|
+
const group = markKitOrigin3(kit.group(), { owner: "game-weapons-three", kind: "ammunition", id: shape });
|
|
6057
6139
|
const cartridge = buildCartridge(kit, dims, shape);
|
|
6058
6140
|
cartridge.scale.setScalar(1e-3);
|
|
6059
6141
|
cartridge.rotation.z = -Math.PI / 2;
|
|
@@ -7914,7 +7996,7 @@ function weaponThumbnailUrl(id, base = DEFAULT_THUMBNAIL_BASE) {
|
|
|
7914
7996
|
}
|
|
7915
7997
|
|
|
7916
7998
|
// src/world-explosives.ts
|
|
7917
|
-
import { buildItem } from "@adatechnology/game-items-three";
|
|
7999
|
+
import { buildItem as buildItem2 } from "@adatechnology/game-items-three";
|
|
7918
8000
|
var WORLD_EXPLOSIVE_PREFIX = "world_";
|
|
7919
8001
|
var P13_VALVE_MESH = "valve";
|
|
7920
8002
|
var P13_VALVE_COLOR = 12095802;
|
|
@@ -7955,7 +8037,7 @@ var meshOf = (THREE, shape) => {
|
|
|
7955
8037
|
};
|
|
7956
8038
|
var modelOf = (THREE, shape, wear = 0) => {
|
|
7957
8039
|
if (!shape.model) return void 0;
|
|
7958
|
-
const { root, kind } =
|
|
8040
|
+
const { root, kind } = buildItem2(THREE, shape.model, { wear });
|
|
7959
8041
|
if (kind !== "model") return void 0;
|
|
7960
8042
|
root.traverse((node) => {
|
|
7961
8043
|
const mesh = node;
|
|
@@ -8231,23 +8313,20 @@ var TEXT = {
|
|
|
8231
8313
|
};
|
|
8232
8314
|
var textOf = (locale) => TEXT[locale] ?? TEXT.en;
|
|
8233
8315
|
var fill = (template, vars) => template.replace(/\{(\w+)\}/g, (_, key) => String(vars[key] ?? ""));
|
|
8234
|
-
var
|
|
8235
|
-
|
|
8316
|
+
var COUNTER_FURNITURE = "buffet";
|
|
8317
|
+
var counterItem = (name) => {
|
|
8318
|
+
const counter = (THREE) => furnitureSpec(THREE, COUNTER_FURNITURE, { w: COUNTER.depth, d: COUNTER.length, h: COUNTER.height });
|
|
8236
8319
|
return {
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
joints: [
|
|
8245
|
-
{ a: "top", b: "side_a", kind: "screw" },
|
|
8246
|
-
{ a: "top", b: "side_b", kind: "screw" }
|
|
8247
|
-
],
|
|
8248
|
-
tags: ["furniture"]
|
|
8320
|
+
id: COUNTER_ITEM_ID,
|
|
8321
|
+
name,
|
|
8322
|
+
build: (THREE) => {
|
|
8323
|
+
const piece = counter(THREE);
|
|
8324
|
+
const root = piece.build(THREE);
|
|
8325
|
+
root.userData.counterSpec = { ...piece.spec, name, tags: [...piece.spec.tags ?? [], "furniture"] };
|
|
8326
|
+
return root;
|
|
8249
8327
|
},
|
|
8250
|
-
|
|
8328
|
+
spec: (root) => root.userData.counterSpec,
|
|
8329
|
+
movable: false
|
|
8251
8330
|
};
|
|
8252
8331
|
};
|
|
8253
8332
|
var targetProp = (id, name) => {
|
|
@@ -8270,7 +8349,7 @@ var targetProp = (id, name) => {
|
|
|
8270
8349
|
};
|
|
8271
8350
|
var weaponItem = (def, name) => {
|
|
8272
8351
|
const id = `${WEAPON_ITEM_PREFIX}${def.id}`;
|
|
8273
|
-
if (!hasWeaponModel(def.id)) return asItem(id, name, weaponProp(def, name), { weapon: def.id, movable: true });
|
|
8352
|
+
if (!hasWeaponModel(def.id) && !itemModelOfWeapon(def.id)) return asItem(id, name, weaponProp(def, name), { weapon: def.id, movable: true });
|
|
8274
8353
|
return {
|
|
8275
8354
|
id,
|
|
8276
8355
|
name,
|
|
@@ -8288,6 +8367,10 @@ var mountedM134Item = (def, name) => ({
|
|
|
8288
8367
|
weapon: def.id,
|
|
8289
8368
|
movable: false
|
|
8290
8369
|
});
|
|
8370
|
+
var targetItem = (id, name) => {
|
|
8371
|
+
const prop = targetProp(id, name);
|
|
8372
|
+
return { id, name, build: (THREE) => markKitOrigin4(buildProp(THREE, prop), { owner: "game-weapons-three", kind: "target", id }), spec: prop.spec, movable: false };
|
|
8373
|
+
};
|
|
8291
8374
|
var asItem = (id, name, prop, extra = {}) => ({
|
|
8292
8375
|
id,
|
|
8293
8376
|
name,
|
|
@@ -8359,8 +8442,8 @@ function createWeaponsTestModule(options = {}) {
|
|
|
8359
8442
|
},
|
|
8360
8443
|
items: () => [
|
|
8361
8444
|
...weaponDefs.map((def) => withThumbnail(weaponItem(def, arsenal.name(def.id)), def.id)),
|
|
8362
|
-
|
|
8363
|
-
...TARGETS.map((target) =>
|
|
8445
|
+
counterItem(text.counter),
|
|
8446
|
+
...TARGETS.map((target) => targetItem(target.id, text.targets[target.id] ?? target.id)),
|
|
8364
8447
|
...worldExplosives.map((item) => withThumbnail(item, item.id.slice(WORLD_EXPLOSIVE_PREFIX.length))),
|
|
8365
8448
|
...mountedM134.map((item) => withThumbnail(item, MOUNTED_M134.weaponId))
|
|
8366
8449
|
],
|
|
@@ -8489,6 +8572,9 @@ function createWeaponsTestModule(options = {}) {
|
|
|
8489
8572
|
import { EXPLOSIONS } from "@adatechnology/game-vfx";
|
|
8490
8573
|
import { createArsenal as createArsenal2 } from "@adatechnology/game-weapons";
|
|
8491
8574
|
|
|
8575
|
+
// src/explosives-bench.ts
|
|
8576
|
+
import { markKitOrigin as markKitOrigin5 } from "@adatechnology/game-contracts";
|
|
8577
|
+
|
|
8492
8578
|
// src/explosives-text.ts
|
|
8493
8579
|
var EXPLOSIVES_TEXT = {
|
|
8494
8580
|
en: {
|
|
@@ -8748,7 +8834,7 @@ function createExplosivesBench(options) {
|
|
|
8748
8834
|
return new (T()).LineLoop(geometry, new (T()).LineBasicMaterial({ color: colour }));
|
|
8749
8835
|
};
|
|
8750
8836
|
const drawRings = (vessel) => {
|
|
8751
|
-
const group = new (T()).Group();
|
|
8837
|
+
const group = markKitOrigin5(new (T()).Group(), { owner: "game-weapons-three", kind: "aid" });
|
|
8752
8838
|
group.name = "blast_rings";
|
|
8753
8839
|
const lethal = lethalOf(vessel);
|
|
8754
8840
|
const injury = injuryOf(vessel);
|
|
@@ -9476,6 +9562,7 @@ export {
|
|
|
9476
9562
|
applyCondition,
|
|
9477
9563
|
buildCartridge,
|
|
9478
9564
|
buildCasing,
|
|
9565
|
+
buildItemWeaponModel,
|
|
9479
9566
|
buildProp,
|
|
9480
9567
|
buildRound,
|
|
9481
9568
|
buildToolClips,
|
|
@@ -9492,11 +9579,13 @@ export {
|
|
|
9492
9579
|
explosivesTextOf,
|
|
9493
9580
|
fitAttachmentModels,
|
|
9494
9581
|
hasWeaponModel,
|
|
9582
|
+
itemModelOfWeapon,
|
|
9495
9583
|
mechanicalSoundOf,
|
|
9496
9584
|
modelKit,
|
|
9497
9585
|
mountFrame,
|
|
9498
9586
|
partRegistry,
|
|
9499
9587
|
projectileModel,
|
|
9588
|
+
registerWeaponItemModel,
|
|
9500
9589
|
rigStock,
|
|
9501
9590
|
rigUnderbarrel,
|
|
9502
9591
|
weaponProp,
|