swift502 / Sketchbook

3D playground built on three.js and cannon.js.
https://jblaha.art/sketchbook/latest
MIT License
1.47k stars 389 forks source link

Support keyboard control with other language #1

Closed aleqsunder closed 5 years ago

aleqsunder commented 5 years ago

For those who do not have English or it is difficult for them to translate the keyboard language into the desired language + mouse click event

Sorry for my English

swift502 commented 5 years ago

Thank you so much! You've made me really happy. I didn't expect anyone to go through my code this early. ๐Ÿ™‚

Just a few small issues.

  1. The most recent branch is the dev branch. Next time please create a pull request there. This time I'll just commit it myself in the dev branch.
  2. I'm getting keyCode 16 for Shift (running), not 13. Is it a typo or is it really different for you? 13 is Enter for me.
  3. Also event.which is apparently non-standard? What's wrong with event.button? I'm already using event.button in the InputManager.

https://github.com/swift502/Sketchbook/blob/bbadaef0d3a61b3c63276ff11bdd010afbc81e90/src/js/sketchbook/InputManager.js#L77

Also, we already identify keys and mouse buttons in the InputManager, I don't think we need to call the SetControl() function twice, because keys and mouse buttons are both "actions".

https://github.com/swift502/Sketchbook/blob/15b27e8e2aecd1d67e9bf2c010430ef2d787a6f8/src/js/sketchbook/GameModes.js#L291-L299

For now I've removed this bit because I don't understand why you made it, but please explain it to me. Maybe I'm just misunderstanding?


I've already commited your changes to the dev branch and tried to fix some of the issues I had experienced and described above. Try the changes and see if it works as intended for you. Everything seems to work for me. jblaha.art

And again, thanks a lot for taking the time to help me! ๐Ÿ™‚

swift502 commented 5 years ago

I'm thinking of using the keycode package to maintain compatibility but also keep the code easy to read.

aleqsunder commented 5 years ago

I use the google.translator, so that I can incorrectly express through him what I wanted to say, I apologize for this)

I have a little experience with github, and I donโ€™t know how to make requests correctly)

Yes, I incorrectly specified the value of Shift by accident, since I initially deobfuscated the sketchbook.min.js and edited it, and there I wrote interaction with the object when I pressed enter (I donโ€™t know how to build a project from the js folder I have), thanks for the amendment!

I used to use which in the interaction with the mouse, and only now I realized that it is not included in the standards, thanks for the event.button)

Yes, I wrote to you on youtube about the model, and yesterday we finally figured out how to solve the problem in the blender itself) We simply use the custom property in blender, and thus assign the model (plane) two parameters: (physics: trimesh) and (visible: true): https://imgur.com/dGzPQVe https://imgur.com/wMD1rzM

But you have a duplicate layer in your project that combines all individual models. I can ask why this decision was taken? https://imgur.com/RpumO2Y https://imgur.com/gn2lBbt

Thanks in advance for the answer)

swift502 commented 5 years ago

No need to apologize. I understand you very well. ๐Ÿ™‚ I hope you can understand me as well.

Custom properties

That's great! I tried to use custom properties in Blender but it didn't work for me. The custom properties wouldn't export. So I used the Three.js online editor to assign custom properties.

But it works for you, so I might try it again with Blender 2.8.

Duplicate layer

Having two models like I have isn't necessary. It's just optimisation.

First I made all the physics objects to test all the different physics types and made them invisible, because they have to be convex, and texturing convex objects like this would be really inefficient. https://imgur.com/8B9qBbw

So I made one visible model (the object named "Sphere"), which is optimised to not waste texture space for the baked ambient occlusion texture.

aleqsunder commented 5 years ago

If i understand that you mean: Export custom properties https://imgur.com/k7YVyz0

Writing custom properties When exporting parameters need to enter in the Object tab of the desired model, not at Scene or World tab: https://imgur.com/OKTTUu1

For Duplicate Use two layers for physics and texture is comfortably, thanks)

swift502 commented 5 years ago

Thanks I'll try it! If the input works OK for you I think we can close this for now. I'll try to implement the mentioned keycode package but functionally that shouldn't change anything.