@adatechnology/game-weapons-three 0.9.0 → 0.10.1

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.js CHANGED
@@ -1536,6 +1536,8 @@ var HAND_HOLD = {
1536
1536
  /** Closure of the fingers on a grip and on a forend (0 open, 1 closed). */
1537
1537
  closed: 0.9,
1538
1538
  forend: 0.6,
1539
+ /** How far the shooting hand slides on its grip so the thumb reaches the safety lever. */
1540
+ thumbReach: 0.02,
1539
1541
  /** How fast the supporting hand goes to the magazine and back, per second. */
1540
1542
  magRate: 7,
1541
1543
  /** The hands shrink with the tool: a tool drawn at scale `s` takes hands at `s ** handScaleExponent`. */
@@ -5501,9 +5503,14 @@ function faultClips(context) {
5501
5503
  );
5502
5504
  return [misfire, ...stopped];
5503
5505
  }
5506
+ var SAFETY_MOTION = { cant: 0.22, lift: 0.012, in: 0.14, flickAt: 0.16, flick: 0.1, outAt: 0.32, out: 0.16, lever: 0.6 };
5504
5507
  function safetyClips(context) {
5505
- if (!context.parts.safety) return [];
5506
- return [composeClip("safety_on", [turn("safety", "z", 0, 0.12, 0, -0.6)]), composeClip("safety_off", [turn("safety", "z", 0, 0.12, -0.6, 0)]), composeClip("mode", [turn("safety", "z", 0, 0.07, 0, 0.4), turn("safety", "z", 0.07, 0.07, 0.4, 0)])];
5508
+ const { cant, lift, in: rise, flickAt, flick, outAt, out, lever } = SAFETY_MOTION;
5509
+ const carry = () => [turn(ROOT, "x", 0, rise, 0, cant), move(ROOT, "y", 0, rise, 0, lift), turn(ROOT, "x", outAt, out, cant, 0), move(ROOT, "y", outAt, out, lift, 0)];
5510
+ const flickTo = (from, to) => context.parts.safety ? [turn("safety", "z", flickAt, flick, from, to)] : [];
5511
+ const clips = [composeClip("safety_on", [...carry(), ...flickTo(0, -lever)]), composeClip("safety_off", [...carry(), ...flickTo(-lever, 0)])];
5512
+ if (context.parts.safety) clips.push(composeClip("mode", [turn("safety", "z", 0, 0.07, 0, 0.4), turn("safety", "z", 0.07, 0.07, 0.4, 0)]));
5513
+ return clips;
5507
5514
  }
5508
5515
  var drawClip = () => composeClip("draw", [move(ROOT, "y", 0, 0.35, -0.1, 0), turn(ROOT, "z", 0, 0.35, -0.6, 0)]);
5509
5516
 
@@ -6744,8 +6751,169 @@ var hand_work_default = {
6744
6751
  hand: "L",
6745
6752
  anchor: "cylinder_side",
6746
6753
  merge: 1
6754
+ },
6755
+ {
6756
+ family: "pistol",
6757
+ clips: [
6758
+ "safety_on",
6759
+ "safety_off"
6760
+ ],
6761
+ hand: "R",
6762
+ anchor: "thumb_safety",
6763
+ whole: true,
6764
+ lead: 0.3,
6765
+ tail: 0.3
6766
+ },
6767
+ {
6768
+ family: "revolver",
6769
+ clips: [
6770
+ "safety_on",
6771
+ "safety_off"
6772
+ ],
6773
+ hand: "R",
6774
+ anchor: "thumb_safety",
6775
+ whole: true,
6776
+ lead: 0.3,
6777
+ tail: 0.3
6778
+ },
6779
+ {
6780
+ family: "rifle",
6781
+ clips: [
6782
+ "safety_on",
6783
+ "safety_off"
6784
+ ],
6785
+ hand: "R",
6786
+ anchor: "thumb_safety",
6787
+ whole: true,
6788
+ lead: 0.3,
6789
+ tail: 0.3,
6790
+ style: "ar"
6791
+ },
6792
+ {
6793
+ family: "p90",
6794
+ clips: [
6795
+ "safety_on",
6796
+ "safety_off"
6797
+ ],
6798
+ hand: "R",
6799
+ anchor: "thumb_safety",
6800
+ whole: true,
6801
+ lead: 0.3,
6802
+ tail: 0.3
6803
+ },
6804
+ {
6805
+ family: "pump",
6806
+ clips: [
6807
+ "safety_on",
6808
+ "safety_off"
6809
+ ],
6810
+ hand: "R",
6811
+ anchor: "thumb_safety",
6812
+ whole: true,
6813
+ lead: 0.3,
6814
+ tail: 0.3
6815
+ },
6816
+ {
6817
+ family: "semi12",
6818
+ clips: [
6819
+ "safety_on",
6820
+ "safety_off"
6821
+ ],
6822
+ hand: "R",
6823
+ anchor: "thumb_safety",
6824
+ whole: true,
6825
+ lead: 0.3,
6826
+ tail: 0.3
6827
+ },
6828
+ {
6829
+ family: "semiint",
6830
+ clips: [
6831
+ "safety_on",
6832
+ "safety_off"
6833
+ ],
6834
+ hand: "R",
6835
+ anchor: "thumb_safety",
6836
+ whole: true,
6837
+ lead: 0.3,
6838
+ tail: 0.3
6839
+ },
6840
+ {
6841
+ family: "break",
6842
+ clips: [
6843
+ "safety_on",
6844
+ "safety_off"
6845
+ ],
6846
+ hand: "R",
6847
+ anchor: "thumb_safety",
6848
+ whole: true,
6849
+ lead: 0.3,
6850
+ tail: 0.3
6851
+ },
6852
+ {
6853
+ family: "bolt",
6854
+ clips: [
6855
+ "safety_on",
6856
+ "safety_off"
6857
+ ],
6858
+ hand: "R",
6859
+ anchor: "thumb_safety",
6860
+ whole: true,
6861
+ lead: 0.3,
6862
+ tail: 0.3
6863
+ },
6864
+ {
6865
+ family: "boltmag",
6866
+ clips: [
6867
+ "safety_on",
6868
+ "safety_off"
6869
+ ],
6870
+ hand: "R",
6871
+ anchor: "thumb_safety",
6872
+ whole: true,
6873
+ lead: 0.3,
6874
+ tail: 0.3
6875
+ },
6876
+ {
6877
+ family: "lever",
6878
+ clips: [
6879
+ "safety_on",
6880
+ "safety_off"
6881
+ ],
6882
+ hand: "R",
6883
+ anchor: "thumb_safety",
6884
+ whole: true,
6885
+ lead: 0.3,
6886
+ tail: 0.3
6887
+ },
6888
+ {
6889
+ family: "belt",
6890
+ clips: [
6891
+ "safety_on",
6892
+ "safety_off"
6893
+ ],
6894
+ hand: "R",
6895
+ anchor: "thumb_safety",
6896
+ whole: true,
6897
+ lead: 0.3,
6898
+ tail: 0.3
6899
+ },
6900
+ {
6901
+ family: "rifle",
6902
+ clips: [
6903
+ "safety_on",
6904
+ "safety_off"
6905
+ ],
6906
+ hand: "L",
6907
+ anchor: "lever_right",
6908
+ style: "ak",
6909
+ whole: true,
6910
+ lead: 0.3,
6911
+ tail: 0.3
6747
6912
  }
6748
- ]
6913
+ ],
6914
+ safety: {
6915
+ comment: "Safety on and off (B): the shooting hand slides up its grip so the thumb flicks the lever while the clip cants the weapon; an AK-style rifle (akCharge) has its big lever on the right, pushed by the support hand over the top."
6916
+ }
6749
6917
  };
6750
6918
 
6751
6919
  // src/fx/hand-work.ts
@@ -6773,6 +6941,18 @@ var anchorsOf = (THREE, model, right) => {
6773
6941
  if (!right || !parts.slide) return null;
6774
6942
  return { part: right.part, offset: right.offset.clone().add(V2(THREE, 0, 0.012, 0)), quaternion: right.quaternion };
6775
6943
  }
6944
+ if (kind === "thumb_safety") {
6945
+ if (!right) return null;
6946
+ const toward = parts.safety ? right.part.worldToLocal(parts.safety.getWorldPosition(V2(THREE, 0, 0, 0))).sub(right.offset) : V2(THREE, 0, HAND_HOLD.thumbReach, 0);
6947
+ return { part: right.part, offset: right.offset.clone().add(toward.clampLength(0, HAND_HOLD.thumbReach)), quaternion: right.quaternion };
6948
+ }
6949
+ if (kind === "lever_right") {
6950
+ const receiver = parts.bolt ?? parts.boltHandle;
6951
+ if (!receiver) return null;
6952
+ const b2 = boxIn(THREE, root, receiver);
6953
+ const x = parts.trigger ? root.worldToLocal(parts.trigger.getWorldPosition(V2(THREE, 0, 0, 0))).x : b2.min.x;
6954
+ return anchorAt(receiver, V2(THREE, x, b2.getCenter(V2(THREE, 0, 0, 0)).y, b2.max.z + palm), handFrame(THREE, V2(THREE, 1, 0, 0), V2(THREE, 0, 0, 1)));
6955
+ }
6776
6956
  if (!part) return null;
6777
6957
  const b = boxIn(THREE, root, part);
6778
6958
  const c = b.getCenter(V2(THREE, 0, 0, 0));