@adatechnology/game-characters-three 0.10.0 → 0.11.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.global.js +14 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1048,6 +1048,7 @@ var createPlayerAvatar = (THREE, options = {}) => {
|
|
|
1048
1048
|
parent.add(mesh);
|
|
1049
1049
|
return mesh;
|
|
1050
1050
|
};
|
|
1051
|
+
const TRIGGER_CURL = 1.22;
|
|
1051
1052
|
const hands = [];
|
|
1052
1053
|
rig.arms.forEach((arm, index) => {
|
|
1053
1054
|
const el = arm.el;
|
|
@@ -1448,6 +1449,13 @@ var createPlayerAvatar = (THREE, options = {}) => {
|
|
|
1448
1449
|
if (run || fall > 0) return;
|
|
1449
1450
|
root.updateMatrixWorld(true);
|
|
1450
1451
|
armReach.apply(targets, view);
|
|
1452
|
+
for (const hand of hands) {
|
|
1453
|
+
const curl = hand.side < 0 ? targets?.fingers?.index : targets?.fingersL?.index;
|
|
1454
|
+
if (curl === void 0 || !hand.fingers[1]) continue;
|
|
1455
|
+
const k = TRIGGER_CURL * Math.min(1, Math.max(0, curl));
|
|
1456
|
+
hand.fingers[0].rotation.z = -hand.side * k * 0.9;
|
|
1457
|
+
hand.fingers[1].rotation.z = -hand.side * k * 1.1;
|
|
1458
|
+
}
|
|
1451
1459
|
},
|
|
1452
1460
|
on(_type, listener) {
|
|
1453
1461
|
listeners.add(listener);
|
|
@@ -1902,7 +1910,7 @@ function createFirstPersonArms(THREE, options = {}) {
|
|
|
1902
1910
|
const channelPose = newPose(THREE);
|
|
1903
1911
|
const mixed = newPose(THREE);
|
|
1904
1912
|
const dropped = newPose(THREE);
|
|
1905
|
-
|
|
1913
|
+
const indexCurl = { R: void 0, L: void 0 };
|
|
1906
1914
|
const bone = createTwoBone(THREE);
|
|
1907
1915
|
const shoulder = new THREE.Vector3();
|
|
1908
1916
|
const wristAt = new THREE.Vector3();
|
|
@@ -1966,7 +1974,7 @@ function createFirstPersonArms(THREE, options = {}) {
|
|
|
1966
1974
|
arm.anchor.quaternion.copy(pose.q);
|
|
1967
1975
|
arm.anchor.scale.setScalar(scale);
|
|
1968
1976
|
arm.hand.setGrip(pose.grip);
|
|
1969
|
-
arm.hand.setIndex(arm.side
|
|
1977
|
+
arm.hand.setIndex(indexCurl[arm.side]);
|
|
1970
1978
|
arm.joints.shoulder.copy(shoulder);
|
|
1971
1979
|
arm.joints.elbow.copy(bone.joint);
|
|
1972
1980
|
arm.joints.wrist.copy(bone.end);
|
|
@@ -2052,7 +2060,7 @@ function createFirstPersonArms(THREE, options = {}) {
|
|
|
2052
2060
|
desired.p.add(bobOffset);
|
|
2053
2061
|
}
|
|
2054
2062
|
modeOf(mode, arm);
|
|
2055
|
-
|
|
2063
|
+
indexCurl[side] = mode === "target" ? side === "R" ? targets?.fingers?.index : targets?.fingersL?.index : void 0;
|
|
2056
2064
|
arm.blend = blendSeconds <= 0 ? 1 : Math.min(1, arm.blend + dt / blendSeconds);
|
|
2057
2065
|
if (arm.blend >= 1) copyPose(arm.shown, desired);
|
|
2058
2066
|
else mixPose(THREE, arm.shown, arm.from, desired, ease(arm.blend));
|