The error is triggered on
scene.activeCamera.rotationQuaternion *= pendingDeviceQuat;
Being scene already defined and pendingDeviceQuat a valid quaternion.
Fully reproducible sample here (thanks for the playground!) https://www.babylonjs-playground.com/#UF6PT9#15
Thank you in advance.