Problem when checkCollisions and useRightHandedSystem are used together

Hi, I’m currently working on porting an app from Three.js to Babylon.js, and I’m encountering a problem that seems like a bug to me… Here’s a playground showing the issue. You end up sinking through the floor as you walk around, and if you try walk into the hilly area, you just immediately glitch through the floor. This only happens if useRightHandedSystem is enabled, but unfortunately I need that enabled in order to be compatible with the existing worlds created using Three.js …

I don’t really know if there’s a way around this, or if I’m just doing something wrong…

By the way, when loading the playground if you experience lag you should set it to use 4.2.0, not Latest (5.0.0), since Babylon v5 currently freezes up the entire browser for 15 seconds or so while loading the model, not sure why…

Hi there, welcome to the Babylon community!

About the collision issue, it does seem to be a bug, thanks for finding that! This seems to only happen when colliding with a mesh terrain, not with a plane or something created from CreateGroundFromHeightMap, weirdly: Ground From Height Map Examples | Babylon.js Playground (babylonjs.com) :thinking:

I’ve opened an issue and am taking a quick look at it, hopefully is a simple fix: Incorrect camera collisions when scene is right handed · Issue #11688 · BabylonJS/Babylon.js (github.com)

2 Likes

Thank you :pray: if you can think of a workaround in the mean time as well, please let me know… I was thinking of trying to create a clone of the mesh, making it hidden and flipping the normals… I’ll try that when I get some time as well

That might be a good workaround. Another thing I thought of was adding physics on the scene and associating the camera with some kind of “player” object that walks around the world.

Hi @carolhmj, I’m back at work today… It’s great to see that’s there’s a fix already! Is this going to be released as a 4.x version, or should I just fork it and pull in that change myself?

1 Like

As a general rule, we don’t backport fixes into a previous version, so this is only on 5 beta, sorry :frowning: But 5 is back-compatible with 4, so you could try updating too :smiley:

Unfortunately I can’t use v5 until the loading issue I mentioned above is fixed, but I’ll look into doing a fork in the mean time :+1: thanks!

About the loading issue, I created an issue on Github so we can keep track of it Browser freezes when loading model · Issue #11747 · BabylonJS/Babylon.js (github.com)

1 Like

Great :+1: if that is fixed, I can use v5 directly

2 Likes

Hi @carolhmj - I see the freeze when loading models is fixed, but there’s also a freeze when loading a CubeMap texture as well, and this one happens on v4.2.1 as well as on v5 … here’s an updated playground where you can see the issue: https://www.babylonjs-playground.com/#I6J7UZ#58

It seems to be caused by hundreds of calls to a ConvertCubeMapToSphericalPolynomial function … is this a bug or is there a smoother way to load this texture?

[quote=“jjv360, post:12, topic:26248”]ConvertCubeMapToSphericalPolynomial[/quote] is a really CPU heavy operation that should only be used once per scene when loading your environment texture.

This is actually only one call to it in your scene but the environment is rather large 1024 size cubemap.

In your case you should either generate the polynomials offline and apply them to the texture or better rely on an .env texture instead of pngs in your playground: Using An HDR Environment For PBR | Babylon.js Documentation

A quick hack would be to force black harmonics :slight_smile: https://www.babylonjs-playground.com/#I6J7UZ#59

texture.sphericalPolynomial = new BABYLON.SphericalPolynomial();

Thanks, this works :+1: in fact the “quick hack” seems to work perfectly and I can’t even tell the difference :thinking: