matthias-schuetz / THREE-BasicThirdPersonGame

JavaScript starter kit for your next WebGL 3D game based on THREE.js + Cannon.js
http://matthiasschuetz.com/three-basicthirdpersongame/
MIT License
146 stars 36 forks source link

game code and other things #2

Closed waldenn closed 6 years ago

waldenn commented 9 years ago

Hi Matthias,

I was wondering if you could also opensource the code for this game you made: http://matthiasschuetz.com/webgl-platforms-game/

I was trying to see how to use your game framework (like how to add a level, GUI, sound, etc.) and not everything was clear to me after looking through the documentation and the provided code demos.

Another thing I briefly looked at was to upgrade the Cannon.js code (upgrading Three.js worked fine after minor fixes), but got stuck somewhere. How difficult would it be to upgrade the Cannon.js code? Should I give it a try again and submit the issues here?

Something else I would be interested in (not sure how difficult that it be), is to also add a first-person mode, much like I coded in this small demo: http://spirare.js.org/app/examples/first-person-navmesh/index.html

Thanks for an interesting framework!

Jama

matthias-schuetz commented 9 years ago

Hi,

sorry for the late answer, I was a little busy during the last weeks.

So concerning the code of my Platforms game, I think I can provide it here as open source. I will check the code, add some more comments and I will publish it soon!

The upgrade topic is a bit more tough: at the time of starting the THREE.BasicThirdPersonGame framework, there was this certain version of Cannon.js I used for the framework. When I was done with the project, there were newer versions of THREE.js and Cannon.js. And I also tried to update both of the frameworks but there were many obstacles. One pitfall lies in the fact that the Cannon.js code has been refactored in 0.6.0 and some methods still don't exist anymore or work different. The only thing I can offer here is to retry the process by using the current versions of both libraries and see how far I can go.

Regarding the first-person mode I can say that it's not a trivial task since the framework was made for 3rd-person games. The critical point can be seen in this picture of the documentation: http://matthiasschuetz.com/three-basicthirdpersongame/docs#basic-concept

The camera is always behind the player object and acts as follow-camera. A first-person camera would behave in a different fashion and you would additionally want to use the mouse to look around (like in your demo). So for this, I could provide two possibilities: You can fake a first-person mode by adjusting the parameters of the camera to something like this.

_game.player.cameraOffsetH = 10; _game.player.cameraOffsetV = 2;

After finding a good camera position, you could hide the player model:

_game.player.mesh.visible = false;

That could do it but it would just be a shift of the 3rd-person follow-camera.

The other possibility is to check out this demo since it's made by the author of Cannon.js and integrates the physics engine into a first-person-like game: https://schteppe.github.io/cannon.js/examples/threejs_fps.html

So far.

waldenn commented 9 years ago

Hi,

Great to see you might opensource the larger demo game. Thanks.

Perhaps it would be a good idea to put the tutorial docs on github too in markdown format in "doc" directory eg.? Then it would be easy make doc. changes as the code changes (and developers would also have the docs in their checkout). I could help with that documention conversion if you want (I am thinking of one big markdown tutorial file with the images and such and a table of contents).

The THREE.js upgrade was easy. I think I had to make 2 small changes, I could make a pull request for that if you want.

I am still in the process of learning more about Cannon.js (my older laptop is also not able to run all their demos), but will try to help with the library interface code upgrade once I understand it better. I think it is important to try and keep tracking the stable version of these libraries, so game developers can feel more confident about the future of the framework. I personally would like to use it to teach some young-adults to make (small) 3D web games.

I will have a go at using the FP-mode with Pointerlock using the model-hiding technique this weekend and report back here. Perhaps some other things could be improved for it to make FP-mode work nicely too.

Thanks!

Jama

matthias-schuetz commented 9 years ago

Hi,

I got some news, so the Platforms demo game is now open source and available here: https://github.com/matthias-schuetz/webgl-platforms-game

I also created a DOCS.md which contains the whole documentation of the website. It's added to the repository and can be found in the doc folder: https://github.com/matthias-schuetz/THREE-BasicThirdPersonGame/blob/master/doc/DOCS.md

The last thing refers to the update of THREE.js and Cannon.js. I started updating both libraries to the current versions but it's still not running. THREE.js wasn't a problem but I'm currently stuck with Cannon.js. I'm going forward with the process and let you know when I have a kind of result.

Regards Matthias

waldenn commented 9 years ago

Fantastic! Great news. No hurries, take your time. I will follow the progress.

Jama