schteppe / cannon.js

A lightweight 3D physics engine written in JavaScript.
http://schteppe.github.com/cannon.js
MIT License
4.71k stars 711 forks source link

Demos broken with three.js r51 #34

Closed ghost closed 12 years ago

ghost commented 12 years ago

Hi Stefan,

First off, great work so far! I'm a complete n00b hobby developer trying my hand at a webgl game and find cannonjs+threejs a lovely marriage.

I don't know whether it's cannonjs or threejs, but your demos are slightly broken using threejs r51.

All your current demos seem to use a version of threejs called "50dev". Is that a special modified version I need to use with cannonjs, or should I be able to stay current with official releases of threejs?

To be more specific, the "slightly broken" I'm witnessing is that the floor seems to be invisible at first, but after rotating the camera you'll find its just unlit on the top face.

Also objects seem to find rest exactly level with the plane at z=0, instead of what I assume should be above the plane at z=objectheight/2.

Thanks, Stephen

schteppe commented 12 years ago

Nice to hear, Stephen! I've developed the Demo framework so it works with Three.js r50 development version, how it acts together with other versions I have no idea. The only thing I modified in cannon's version of it three.js was removing a console.warn somewhere that produced unnecessary warnings.

A question though; why use my CANNON.Demo framework if you want to make an own game? You'd be better off making an own game-specific renderer. Cannon.js is 100% independent of graphics libraries. You should be able to use any renderer for your game: Three.js, SceneJS, etc, etc. See my notes for usage with Three.js.

In the dev branch of cannon.js, I've simplified the Plane class (removed the .normal property in favor of the RigidBody.quaternion ) and that also simplified the rendering. This may solve your problems with CANNON.Demo and probably also make it easier for you to develop your own renderer.

ghost commented 12 years ago

Thanks for replaying so soon Stefan.

As to why I'm using CANNON.Demo, that's only to debug a headache I'm mulling over at the moment. You quite rightly guessed that I'm developing my own engine/framework for the game. But I ran in to a problem, and debugging it in my framework wasn't helping, so I thought I'd take my framework out of the equation and try using CANNON.Demo to recreate the problem.

In process of getting that done, I noticed the strange ground plane behaviour with threejs r51 dropped in as a replacement for the demos r"50dev". So winding it all back to your official demos, I found that they don't work with that version of threejs.

If you're happy that they don't work with anything other than your custom threejs, than that's fine. I just thought I'd bring it to your attention.

I still haven't figured out my original problem, but I don't think there is any point bringing it up here until I understand it myself.

Thanks, and I hope you retain the enthusiasm to keep working on cannonjs for a long time.

schteppe commented 12 years ago

Okay, then I'm with you. Thanks :)

My plan with CANNON.Demo was to support the most recent versions of Three.js, though I do not see it as very important. It's just a debug renderer, and it does not need the latest flashy rendering features.

You're welcome to ask about your problem anytime. If you could make a jsfiddle using CANNON.Demo showing your problem that'd be awesome.

schteppe commented 12 years ago

I just updated CANNON.Demo so it uses Three.js r51. I agree that using a custom version of it is a bad idea, so I also figured out a way to avoid the console.warn messages from CANNON.Demo itself. Check out the dev branch. https://github.com/schteppe/cannon.js/commit/0f503c32b359759de7213682cbcc73c9c601daa1