@adatechnology/game-weapons-three 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +636 -509
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +19 -13
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1616,9 +1616,7 @@ var HAND_HOLD = {
|
|
|
1616
1616
|
/** How far the shooting hand slides on its grip so the thumb reaches the safety lever. */
|
|
1617
1617
|
thumbReach: 0.02,
|
|
1618
1618
|
/** How fast the supporting hand goes to the magazine and back, per second. */
|
|
1619
|
-
magRate: 7
|
|
1620
|
-
/** The hands shrink with the tool: a tool drawn at scale `s` takes hands at `s ** handScaleExponent`. */
|
|
1621
|
-
handScaleExponent: 0.55
|
|
1619
|
+
magRate: 7
|
|
1622
1620
|
};
|
|
1623
1621
|
var handFrame = (THREE, x, y) => {
|
|
1624
1622
|
const ax = x.clone().normalize();
|
|
@@ -1708,7 +1706,8 @@ function holdOfModel(THREE, model, holderScale) {
|
|
|
1708
1706
|
right,
|
|
1709
1707
|
left,
|
|
1710
1708
|
leftMagazine,
|
|
1711
|
-
scale:
|
|
1709
|
+
// the hands at the tool's scale: a tool drawn smaller than the hands looks like a toy in them
|
|
1710
|
+
scale: holderScale,
|
|
1712
1711
|
grip: HAND_HOLD.closed,
|
|
1713
1712
|
gripLeft: HAND_HOLD.forend
|
|
1714
1713
|
};
|
|
@@ -1723,7 +1722,7 @@ function holdOfProp(THREE, group, category, scale) {
|
|
|
1723
1722
|
const long = head && ["smg", "carbine", "rifle", "sniper", "shotgun", "crossbow", "flame"].includes(category);
|
|
1724
1723
|
const headSize = head ? size(head) : null;
|
|
1725
1724
|
const left = long && head && headSize ? { part: group, offset: head.position.clone().add(V(THREE, -headSize.x * 0.15, -headSize.y / 2 - HAND_HOLD.palm, 0)), quaternion: forendFrame(THREE) } : null;
|
|
1726
|
-
return { right, left, leftMagazine: null, scale
|
|
1725
|
+
return { right, left, leftMagazine: null, scale, grip: HAND_HOLD.closed, gripLeft: HAND_HOLD.forend };
|
|
1727
1726
|
}
|
|
1728
1727
|
|
|
1729
1728
|
// src/props.ts
|
|
@@ -3289,7 +3288,7 @@ var models_default = {
|
|
|
3289
3288
|
};
|
|
3290
3289
|
|
|
3291
3290
|
// src/models/kit.ts
|
|
3292
|
-
import { shapeGeometries } from "@adatechnology/game-shapes-three";
|
|
3291
|
+
import { markShared, shapeGeometries } from "@adatechnology/game-shapes-three";
|
|
3293
3292
|
|
|
3294
3293
|
// src/models/rounded-box.ts
|
|
3295
3294
|
var uvAlong = (THREE, faceDirection, normal, uvAxis, projectionAxis, radius, sideLength) => {
|
|
@@ -3361,7 +3360,7 @@ var createMaterials = (THREE) => {
|
|
|
3361
3360
|
const standard = (color, roughness = 0.7, metalness = 0.2, extra = {}) => new THREE.MeshStandardMaterial({ color, roughness, metalness, ...extra });
|
|
3362
3361
|
const basic = (color, extra = {}) => new THREE.MeshBasicMaterial({ color, ...extra });
|
|
3363
3362
|
const additive = { transparent: true, opacity: 0.95, blending: THREE.AdditiveBlending, depthWrite: false };
|
|
3364
|
-
|
|
3363
|
+
const materials = {
|
|
3365
3364
|
metal: standard(3422010, 0.42, 0.75),
|
|
3366
3365
|
steel: standard(7106418, 0.32, 0.85),
|
|
3367
3366
|
steelL: standard(9080208, 0.28, 0.9),
|
|
@@ -3400,6 +3399,8 @@ var createMaterials = (THREE) => {
|
|
|
3400
3399
|
bakelite: standard(6958620, 0.6, 0),
|
|
3401
3400
|
polyMag: standard(2763302, 0.85, 0)
|
|
3402
3401
|
};
|
|
3402
|
+
markShared(...Object.values(materials));
|
|
3403
|
+
return materials;
|
|
3403
3404
|
};
|
|
3404
3405
|
var kits = /* @__PURE__ */ new WeakMap();
|
|
3405
3406
|
function modelKit(host) {
|
|
@@ -3428,6 +3429,7 @@ function modelKit(host) {
|
|
|
3428
3429
|
let geometry = geometries.get(key);
|
|
3429
3430
|
if (!geometry) {
|
|
3430
3431
|
geometry = radius > 25e-5 ? createRoundedBoxGeometry(THREE, w, h, d, 2, radius) : new THREE.BoxGeometry(w, h, d);
|
|
3432
|
+
markShared(geometry);
|
|
3431
3433
|
geometries.set(key, geometry);
|
|
3432
3434
|
}
|
|
3433
3435
|
const mesh = place(parent, shadowed(new THREE.Mesh(geometry, material)), x, y, z);
|
|
@@ -5209,6 +5211,7 @@ function createBoxFx(options) {
|
|
|
5209
5211
|
}
|
|
5210
5212
|
|
|
5211
5213
|
// src/fx/viewmodel.ts
|
|
5214
|
+
import { discardObject3D as discardObject3D3 } from "@adatechnology/game-shapes-three";
|
|
5212
5215
|
import { createToolClipPlayer, toolAnimationStep } from "@adatechnology/game-contracts";
|
|
5213
5216
|
import { createRng as createRng2, muzzleEnergy as muzzleEnergy3 } from "@adatechnology/game-weapons";
|
|
5214
5217
|
|
|
@@ -6266,6 +6269,7 @@ function createEffects(THREE, sink, random) {
|
|
|
6266
6269
|
}
|
|
6267
6270
|
|
|
6268
6271
|
// src/fx/heavy.ts
|
|
6272
|
+
import { discardObject3D } from "@adatechnology/game-shapes-three";
|
|
6269
6273
|
var PI12 = Math.PI;
|
|
6270
6274
|
var ROCKET_LIGHT_NAME = "rocket-light";
|
|
6271
6275
|
var rocketsInFlight = /* @__PURE__ */ new WeakMap();
|
|
@@ -6319,7 +6323,7 @@ function launchRocket(context, flyRound = true) {
|
|
|
6319
6323
|
if (random() < 0.9) context.effects.smoke(rocket.position.clone().addScaledVector(forward, -0.12), new THREE.Vector3((random() - 0.5) * 0.1, 0.05, (random() - 0.5) * 0.1), 0.02 + random() * 0.015, 2.2, 0.5);
|
|
6320
6324
|
},
|
|
6321
6325
|
() => {
|
|
6322
|
-
rocket
|
|
6326
|
+
discardObject3D(rocket);
|
|
6323
6327
|
exhaust.geometry.dispose();
|
|
6324
6328
|
exhaust.material.dispose();
|
|
6325
6329
|
const remaining = (rocketsInFlight.get(light) ?? 1) - 1;
|
|
@@ -6495,6 +6499,7 @@ var toWorld = (session, vector, scaled = false) => {
|
|
|
6495
6499
|
};
|
|
6496
6500
|
|
|
6497
6501
|
// src/fx/viewmodel-events.ts
|
|
6502
|
+
import { discardObject3D as discardObject3D2 } from "@adatechnology/game-shapes-three";
|
|
6498
6503
|
import { muzzleSmokeOf } from "@adatechnology/game-weapons";
|
|
6499
6504
|
var PI13 = Math.PI;
|
|
6500
6505
|
var UGL_FLASH = 1.6;
|
|
@@ -6657,7 +6662,7 @@ function createClipEventHandler(world, session) {
|
|
|
6657
6662
|
session.model.inner.add(shell);
|
|
6658
6663
|
shell.position.set(-0.25, 0, 0);
|
|
6659
6664
|
world.schedule(0.02, 0.4, (eased) => shell.position.x = -0.25 + 0.6 * eased, () => {
|
|
6660
|
-
shell
|
|
6665
|
+
discardObject3D2(shell);
|
|
6661
6666
|
});
|
|
6662
6667
|
}
|
|
6663
6668
|
}
|
|
@@ -7218,7 +7223,7 @@ function createViewmodel(options) {
|
|
|
7218
7223
|
const release = () => {
|
|
7219
7224
|
if (!session) return;
|
|
7220
7225
|
session.attachments?.dispose();
|
|
7221
|
-
session.model.root
|
|
7226
|
+
discardObject3D3(session.model.root);
|
|
7222
7227
|
player = null;
|
|
7223
7228
|
session = null;
|
|
7224
7229
|
tasks = [];
|
|
@@ -7355,7 +7360,7 @@ function createViewmodel(options) {
|
|
|
7355
7360
|
ahead.set(0, 0, -1).applyQuaternion(camera.quaternion);
|
|
7356
7361
|
if (reach === 0) reach = Math.max(0.01, measureReach(session));
|
|
7357
7362
|
const free = options.contact(camera.position, ahead, WALL_PULL.probe);
|
|
7358
|
-
const want = free === null ? 0 : Math.max(0, Math.min(WALL_PULL.max, reach + WALL_PULL.margin - free));
|
|
7363
|
+
const want = free === null ? 0 : Math.max(0, Math.min(Math.max(WALL_PULL.max, session.lengthMetres * session.holderScale), reach + WALL_PULL.margin - free));
|
|
7359
7364
|
pull += (want - pull) * Math.min(1, dt * WALL_PULL.rate);
|
|
7360
7365
|
if (pull < 1e-4) return;
|
|
7361
7366
|
hand.position.addScaledVector(ahead, -pull);
|
|
@@ -8861,6 +8866,7 @@ import { EXPLOSIONS } from "@adatechnology/game-vfx";
|
|
|
8861
8866
|
import { createArsenal as createArsenal2 } from "@adatechnology/game-weapons";
|
|
8862
8867
|
|
|
8863
8868
|
// src/explosives-bench.ts
|
|
8869
|
+
import { discardObject3D as discardObject3D4 } from "@adatechnology/game-shapes-three";
|
|
8864
8870
|
import { markKitOrigin as markKitOrigin5 } from "@adatechnology/game-contracts";
|
|
8865
8871
|
|
|
8866
8872
|
// src/explosives-text.ts
|
|
@@ -9137,7 +9143,7 @@ function createExplosivesBench(options) {
|
|
|
9137
9143
|
vessel.rings = group;
|
|
9138
9144
|
};
|
|
9139
9145
|
const clearRings = (vessel) => {
|
|
9140
|
-
vessel.rings
|
|
9146
|
+
if (vessel.rings) discardObject3D4(vessel.rings);
|
|
9141
9147
|
vessel.rings = void 0;
|
|
9142
9148
|
};
|
|
9143
9149
|
const phaseOf = (vessel) => {
|
|
@@ -9226,7 +9232,7 @@ function createExplosivesBench(options) {
|
|
|
9226
9232
|
}
|
|
9227
9233
|
};
|
|
9228
9234
|
const clearShells = () => {
|
|
9229
|
-
|
|
9235
|
+
discardObject3D4(shells.map((shell) => shell.mesh));
|
|
9230
9236
|
shells.length = 0;
|
|
9231
9237
|
};
|
|
9232
9238
|
const fullVitality = /* @__PURE__ */ new Map();
|