• Runtimes
  • [spine-ts] physics 'mode' bug for Physics.none?

In the spine-ts / webgl runtime:

updateWorldTransform(physics) {
  if (!physics)
    throw new Error("physics is undefined");

Changed to:

updateWorldTransform(physics) {
  if (physics === undefined || physics === null)
    throw new Error("physics is undefined");

When we pass the physics parameter as Physics.none = 0 it triggers the throw, but Physics.none is a legitimate state, correct?

Related Discussions
...

Yes, Physics.none being a legitimate state means that the original check if (!physics) incorrectly catches the case where physics is explicitly set to Physics.none (which is 0 and falsy in JavaScript). Your change to check for undefined or null specifically is correct because it allows 0 (or Physics.none) to be a valid value without triggering the error. This adjustment ensures that the method behaves correctly when Physics.none is intended, allowing the method to proceed without advancing the physics state, as per the design of the physics system in Spine.

Ok, want me to create a PR or file a bug?

No, I'm fixing it at the moment. Good catch, thanks!

Released 4.2.42 with the fix to NPM.