threebox icon indicating copy to clipboard operation
threebox copied to clipboard

obj.setRotation has no effect when argument is 0

Open axekan opened this issue 2 years ago • 0 comments

Describe the bug using obj.setRotation with a value of 0 (to reset rotation) has no effect.

I believe it is caused by this line: https://github.com/jscastro76/threebox/blob/f01ed8f9dd7059d27ad83c73adab2dbcdc817bc5/src/objects/objects.js#L128

Where 0 is falsy, causing the right-hand side of the expression to be used instead. This causes the object to just retain its rotation. This is somewhat noticeable when using alt to rotate objects too, where the object will 'skip' over 0 causing a slightly less smooth rotation around the default rotation.

I'm not sure if this is how it is supposed to work, but this could probably be solved easily using ?? (nullish-coalescing) operators instead of ||.

Not sure if this needs a reproducible example / codesandbox. Can provide if necessary.

Version [2.2.7]

axekan avatar Sep 09 '22 09:09 axekan