PaulHax / spin-controls

Arcball style controls for three.js Object3Ds and Cameras. Featuring pointer to trackball accuracy and unlimited rotation.
https://paulhax.github.io/spin-controls/
MIT License
78 stars 12 forks source link

SpinControl.onWindowResize #10

Closed khcyt closed 3 years ago

khcyt commented 3 years ago

Hello, SpinControl class expects a global function onWindowResize (line 627/639 in SpinControl.js). Is that correct? In class SpinControl only function this.onWindowResize() exists. The readme file says that the user should call SpinControl.onWindowResize().

PaulHax commented 3 years ago

Thanks for pointing this out. Only window objects emit resize events these days, so the _this.domElement.addEventListener( 'resize', onWindowResize ); line does nothing.

So on resizing the element with the three.js renderer, the app code should call onWindowResize on the SpinControls object.

khcyt commented 3 years ago

The problem, however, is that the global function onWindowResize usually doesn't exist. The result is a JavaScript runtime error. Therefore I have to define this function explicitly.

PaulHax commented 3 years ago

Again, thanks for this =). If the error does not fire when I open the examples.html locally, I probably don't know about it.

khcyt commented 3 years ago

Thanks for the fix. In your example html file there is a global function onWindowResize(). Because of this, it works with no problem. I want to use CameraSpinControl and SpinControl in my project (thanks for publishing the source files). In my project there is no onWindowResize() function by default. With your fix, it's now working fine.