LucasDower / ObjToSchematic

A tool to convert 3D models into Minecraft formats such as .schematic, .litematic, .schem and .nbt
https://objtoschematic.com/
BSD 3-Clause "New" or "Revised" License
372 stars 42 forks source link

Fixed Camera rotates slower with devtools open #95

Closed 0-zen closed 1 year ago

0-zen commented 1 year ago

Nature of the bug: The devtools augmented significantly the number of calls to onMouseMove() per second (~50 -> ~450), which led to mouse deltas to get smaller. My guess is that it made the update of the mouse position in the model throttle.

Here's what I did:

LucasDower commented 1 year ago

Wow, yeah you're right, onMouseMove() is being called multiple times before getMouseDelta() is read. It looks like when devtools is closed all mouse events are coalesced into one event but when it is open then each event is emitted separately.

I think a better fix would be simply to remove line this.prevMouse = this.currMouse; from onMouseMove(), that way the previous mouse position will stay as the last position a delta was calculated from.

If you wanna update the PR with the change above I'll approve and get this merged. Thanks for pointing out what was wrong, I've taken a stab at this issue a few times and it stumped me so massive thanks.

0-zen commented 1 year ago

No problem 👍 this repo is useful so I might continue to either tackle issues or make improvements. Was a pain to get git to understand where I wanted to push but here you go, the changes are done :)

LucasDower commented 1 year ago

Fixes #75