I need to handle a ThreeJS Matrix4 that holds the position of an element, along with another Matrix4 containing an offset. I want to add this offset to the position in my first Matrix4. Currently, I'm doing it like this:
baseMatrix4.setPosition(new THREE.Vector3().setFromMatrixPosition(baseMatrix4).add(new THREE.Vector3().setFromMatrixPosition(offsetMatrix4)))
The issue is that accessing baseMatrix4 inside the method hinders chaining with previous methods, as baseMatrix4 may be undefined or outdated by then.
Any suggestions on how to improve this and still allow for chaining?