@adatechnology/game-characters-three 0.4.1 → 0.4.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/README.md +4 -4
- package/dist/index.d.ts +9 -2
- package/dist/index.global.js +19 -15
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -4238,6 +4238,7 @@ var player_avatar_default = {
|
|
|
4238
4238
|
var TWO_PI = Math.PI * 2;
|
|
4239
4239
|
var MAX_GAIT = 1.4;
|
|
4240
4240
|
var CLIP_BLEND = 0.12;
|
|
4241
|
+
var CLIP_CASCADE = 5;
|
|
4241
4242
|
var FALL_SECONDS2 = 0.3;
|
|
4242
4243
|
var HIP_HEIGHT = 0.95;
|
|
4243
4244
|
var WALK_ARM = 0.28;
|
|
@@ -4277,6 +4278,7 @@ var createPlayerAvatar = (THREE, options = {}) => {
|
|
|
4277
4278
|
const blendDefault = options.blend ?? CLIP_BLEND;
|
|
4278
4279
|
const fallSeconds = options.fallSeconds ?? FALL_SECONDS2;
|
|
4279
4280
|
const smooth = options.cascade ?? true;
|
|
4281
|
+
const clipCascade = options.clipCascade ?? CLIP_CASCADE;
|
|
4280
4282
|
const root = new THREE.Group();
|
|
4281
4283
|
const tilt = new THREE.Group();
|
|
4282
4284
|
tilt.add(body);
|
|
@@ -4567,14 +4569,14 @@ var createPlayerAvatar = (THREE, options = {}) => {
|
|
|
4567
4569
|
}
|
|
4568
4570
|
placeBody(fall);
|
|
4569
4571
|
stepClip(dt, down);
|
|
4570
|
-
if (smooth) animator.cascade(rig, dt);
|
|
4572
|
+
if (smooth) animator.cascade(rig, run && !run.clip.loop ? dt * clipCascade : dt);
|
|
4571
4573
|
const clipId = run ? run.clip.id : null;
|
|
4572
4574
|
const ph = cycles * TWO_PI;
|
|
4573
4575
|
hands.forEach((hand) => {
|
|
4574
4576
|
const isRight = hand.side < 0;
|
|
4575
4577
|
const holdRight = isRight && (!!state.holding || !!state.itemUse);
|
|
4576
4578
|
const holdLeft = !isRight && (state.itemUse?.id === "open" || state.itemUse?.id === "close");
|
|
4577
|
-
const grip = clipId
|
|
4579
|
+
const grip = clipId?.startsWith("punch_") ? 1.4 : clipId === "shove_two_hands" ? 0.15 : state.armed || holdRight || holdLeft ? 1.22 : running ? 0.85 : 0.12;
|
|
4578
4580
|
const wristSwing = holdRight || state.armed || running ? 0 : -Math.min(1, gait) * Math.sin(ph - 0.6) * 0.12 * hand.side;
|
|
4579
4581
|
setHandGrip(hand, grip, wristSwing);
|
|
4580
4582
|
});
|
|
@@ -5003,10 +5005,11 @@ function createFirstPersonArms(THREE, options = {}) {
|
|
|
5003
5005
|
const palmAt = new THREE.Vector3();
|
|
5004
5006
|
const fingers = new THREE.Vector3();
|
|
5005
5007
|
const towards = new THREE.Vector3();
|
|
5006
|
-
const fromChannel = (channel, side, base, out) => {
|
|
5008
|
+
const fromChannel = (channel, side, base, out, from = side) => {
|
|
5007
5009
|
out.p.set(...channel.p);
|
|
5008
5010
|
out.q.copy(quaternionOf(channel.r));
|
|
5009
|
-
|
|
5011
|
+
const rightNumbers = from === "R" || channel.mirror;
|
|
5012
|
+
if (rightNumbers !== (side === "R")) {
|
|
5010
5013
|
out.p.x = -out.p.x;
|
|
5011
5014
|
out.q.copy(mirrorQuaternion(THREE, out.q));
|
|
5012
5015
|
}
|
|
@@ -5071,7 +5074,7 @@ function createFirstPersonArms(THREE, options = {}) {
|
|
|
5071
5074
|
play(id, options2) {
|
|
5072
5075
|
const clip = clips.get(id);
|
|
5073
5076
|
if (!clip) return false;
|
|
5074
|
-
run = { clip, time: 0, left: options2?.leg === "left" };
|
|
5077
|
+
run = { clip, time: 0, left: options2?.leg === "left", swap: options2?.hand === "left" };
|
|
5075
5078
|
fire(clip, -1e-9, 0);
|
|
5076
5079
|
return true;
|
|
5077
5080
|
},
|
|
@@ -5119,10 +5122,11 @@ function createFirstPersonArms(THREE, options = {}) {
|
|
|
5119
5122
|
arm.blend = blendSeconds <= 0 ? 1 : Math.min(1, arm.blend + dt / blendSeconds);
|
|
5120
5123
|
if (arm.blend >= 1) copyPose(arm.shown, desired);
|
|
5121
5124
|
else mixPose(THREE, arm.shown, arm.from, desired, ease(arm.blend));
|
|
5122
|
-
const
|
|
5125
|
+
const from = run?.swap ? side === "R" ? "L" : "R" : side;
|
|
5126
|
+
const channel = sample?.[from];
|
|
5123
5127
|
let pose;
|
|
5124
5128
|
if (channel && channel.w > 0) {
|
|
5125
|
-
fromChannel(channel, side, arm.shown, channelPose);
|
|
5129
|
+
fromChannel(channel, side, arm.shown, channelPose, from);
|
|
5126
5130
|
mixPose(THREE, mixed, arm.shown, channelPose, channel.w);
|
|
5127
5131
|
pose = mode === "target" ? mixed : keepOutside(mixed, handReach(mixed));
|
|
5128
5132
|
} else pose = mode === "target" ? arm.shown : keepOutside(arm.shown, handReach(arm.shown));
|
|
@@ -5211,9 +5215,9 @@ var toRoomAvatar = (avatar, options = {}) => {
|
|
|
5211
5215
|
strike: (clipId, strikeOptions) => {
|
|
5212
5216
|
const clip = strikes.get(clipId);
|
|
5213
5217
|
if (!clip) return null;
|
|
5214
|
-
const left = strikeOptions?.leg === "left";
|
|
5218
|
+
const left = strikeOptions?.leg === "left" || strikeOptions?.hand === "left";
|
|
5215
5219
|
avatar.play(left ? leftOf(clip) : clip);
|
|
5216
|
-
arms?.play(clipId, left ? { leg: "left" } : void 0);
|
|
5220
|
+
arms?.play(clipId, strikeOptions?.leg === "left" ? { leg: "left" } : strikeOptions?.hand === "left" ? { hand: "left" } : void 0);
|
|
5217
5221
|
return impactOf(clip);
|
|
5218
5222
|
}
|
|
5219
5223
|
};
|