three.js icon indicating copy to clipboard operation
three.js copied to clipboard

ArcballControls is using .clone() unnecessarily

Open WestLangley opened this issue 4 years ago • 6 comments

The three.js convention is to create single instances and reuse them.

WestLangley avatar Nov 12 '21 16:11 WestLangley

Are there any that happen every frame?

mrdoob avatar Nov 15 '21 09:11 mrdoob

Every time the mouse moves.

If the library is consistent in avoiding that pattern, then you don't have to worry about it.

WestLangley avatar Nov 15 '21 12:11 WestLangley

There is still more to be done here...

WestLangley avatar Jan 29 '22 22:01 WestLangley

There is still more to be done here... anyone interested?

WestLangley avatar Jul 12 '22 21:07 WestLangley

I've looked into this issue multiple times but I'm afraid it can only be solved by rewriting major parts of the class. The problem is that certain methods like calculateRotationAxis() or getCursorNDC() return new objects. And the calling code relies on this pattern and assumes to get new objects. Besides, many intermediate objects are not placed in the module scope but are properties of ArcballControls. Every time I have tried to refactor all of this, things started to break. Besides, ArcballControls has by far the biggest code base of all control classes. That makes this task even more time consuming.

I'm not sure its worth to invest a lot of time in this class unless a user reports performance issues.

Mugen87 avatar Jul 14 '22 14:07 Mugen87

Every time I have tried to refactor all of this, things started to break.

This is red flag, then. The OP is not responding, and in addition, four devs have demonstrated little interest in pursuing it further.

If this code is not going to be maintained, it should be hosted elsewhere by someone willing to take responsibility for it.

WestLangley avatar Jul 19 '22 00:07 WestLangley