New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New keyboard controls #101
Conversation
d5db5dc
to
48f2969
Compare
Thanks for contributing this, I think it'll be pretty useful to have this feature. seems like the tests are failing I'm looking at the code, and this seems completely independent from everything. |
Yeah, it's pretty generic, it can be used for any 3d three.js scene. It works by taking in a threejs camera, and a dom element, and listens to page events like keyboard, mouse, touch. Then it applies transformations to the threejs camera based on the inputs. For the use case of panning around the map, I don't think there's much need to make changes to the control code except for constants like movement speed or the camera target (the reference point for rotations). I think the default movement constants are a bit slow for example, but it's just preference based. For things like first person controls or more cinematic camera controls, the user would probably want to define their own controls. If we add in new first-person controls that maps to prismarine-physics instead of the three camera, it would be more integrated to the minecraft/the viewer, but as it stands this should be usable for any threejs program. |
} | ||
|
||
unregisterHandlers() { | ||
this.element.removeEventListener('pointermove', this.onPointerMove, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mentioned on discord that registration is broken, and this seems to be the likely case. These calls aren't actually going to remove anything, because this.onPointerMove.bind(this) !== this.onPointerMove
. Your best bet might be to autobind class properties in the constructor so that you can use this.onPointerMove
everywhere and have it bound to the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed.
Added some dampening/inertia to the electron example so movements are a bit more fluid. Rotations are still a bit annoying, since the rotations happen around the entire scene, maybe they should happen around the center of the screen or what the user is looking at? Also most of the editable properties are documented at https://threejs.org/docs/#examples/en/controls/OrbitControls, we could add this info to the readme. Or we could take this out and put it to its own repo, but I'm not sure if it's worth it for a single file. |
Can you add doc for what is exposed in the readme ? (Next to the rest of the API) |
OrbitalControls with a bit of changes:
Everything is exposed, so it should be easy to update constants (like the moving speed, keyPanSpeed, verticalTranslationSpeed) from the default settings.