TypeError: toValue.subtract is not a function

Hello Babylon.js community,

I’ve discovered a potential bug in the animation system where Vector3 interpolation loses its type during runtime animations.

Description: During scene rendering with runtime animations, the animation._interpolate() method is returning plain objects instead of Vector3 instances for ANIMATIONTYPE_VECTOR3, which causes vector operations of subtraction to fail.

Current Behavior: During interpolation, we get:
fromValue = _Vector3 {_isDirty: true, _x: 375.89759748328, _y: 78.7461339178, _z: -657.0282096862}
toValue = {isDirty: true, x: 1399.8330523717, y: 660.6643702683, z: -849.4280001309}

When trying to perform operations, we get:

TypeError: toValue.subtract is not a function in Line 595 File: runtimeAnimation.ts

Expected Behavior: Both fromValue and toValue should be proper Vector3 instances that maintain their vector operation methods during interpolation.

Environment:

  • Babylon.js version: 7.41.1
  • Occurs in all browsers and OS

Can anyone else confirm this behavior?

Thanks for your help!

Welcome aboard!

Could you make a reproduction in the Playground? I think Vector3 animation is the most common type of animation, it would be strange if nobody had encountered this bug before…

Just looked back at the problem it’s problem from our side we were passing serialized vectors instead of actual vectors causing the problem.
We can close this is not a bug

2 Likes