DeltaZN commited on
Commit
1203e8e
·
1 Parent(s): 86758a1

fix: death animation improvements

Browse files
frontend/src/scene/BeastActor.tsx CHANGED
@@ -283,7 +283,7 @@ function animateDeath(
283
  if (body) {
284
  body.rotation.z = MathUtils.damp(body.rotation.z, Math.PI / 2, 4, delta);
285
  body.rotation.x = MathUtils.damp(body.rotation.x, 0, 4, delta);
286
- body.position.y = MathUtils.damp(body.position.y, -0.34, 4, delta);
287
  }
288
  legRefs.forEach((legRef, index) => {
289
  if (legRef.current) {
 
283
  if (body) {
284
  body.rotation.z = MathUtils.damp(body.rotation.z, Math.PI / 2, 4, delta);
285
  body.rotation.x = MathUtils.damp(body.rotation.x, 0, 4, delta);
286
+ body.position.y = MathUtils.damp(body.position.y, 0.32, 4, delta);
287
  }
288
  legRefs.forEach((legRef, index) => {
289
  if (legRef.current) {
frontend/src/scene/useNpcActorAnimation.ts CHANGED
@@ -148,15 +148,37 @@ function animateDeath(refs: NpcAnimationRefs, delta: number) {
148
  );
149
  }
150
 
151
- dampLimb(refs.leftArmRef, -0.35, delta);
152
- dampLimb(refs.rightArmRef, 0.35, delta);
153
- dampLimb(refs.leftLegRef, 0.22, delta);
154
- dampLimb(refs.rightLegRef, -0.22, delta);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  }
156
 
157
- function dampLimb(ref: RefObject<Group | null>, xRotation: number, delta: number) {
 
 
 
 
 
158
  if (ref.current) {
159
  ref.current.rotation.x = MathUtils.damp(ref.current.rotation.x, xRotation, 5, delta);
 
 
160
  }
161
  }
162
 
 
148
  );
149
  }
150
 
151
+ // Settle the torso and head out of whatever walk/attack pose they were in.
152
+ dampGroupToRest(refs.torsoRef, delta);
153
+ dampGroupToRest(refs.headRef, delta);
154
+
155
+ // Limbs collapse into a relaxed, slightly splayed sprawl. Reset every channel
156
+ // (not just rotation.x) so no leftover stride/chop rotation freezes mid-motion.
157
+ dampLimb(refs.leftArmRef, -0.1, -0.4, delta);
158
+ dampLimb(refs.rightArmRef, -0.1, 0.4, delta);
159
+ dampLimb(refs.leftLegRef, 0.08, -0.18, delta);
160
+ dampLimb(refs.rightLegRef, 0.08, 0.18, delta);
161
+ }
162
+
163
+ function dampGroupToRest(ref: RefObject<Group | null>, delta: number) {
164
+ if (!ref.current) {
165
+ return;
166
+ }
167
+ ref.current.rotation.x = MathUtils.damp(ref.current.rotation.x, 0, 5, delta);
168
+ ref.current.rotation.y = MathUtils.damp(ref.current.rotation.y, 0, 5, delta);
169
+ ref.current.rotation.z = MathUtils.damp(ref.current.rotation.z, 0, 5, delta);
170
  }
171
 
172
+ function dampLimb(
173
+ ref: RefObject<Group | null>,
174
+ xRotation: number,
175
+ zRotation: number,
176
+ delta: number,
177
+ ) {
178
  if (ref.current) {
179
  ref.current.rotation.x = MathUtils.damp(ref.current.rotation.x, xRotation, 5, delta);
180
+ ref.current.rotation.y = MathUtils.damp(ref.current.rotation.y, 0, 5, delta);
181
+ ref.current.rotation.z = MathUtils.damp(ref.current.rotation.z, zRotation, 5, delta);
182
  }
183
  }
184