Hello friends!
I’m generating an open Ribbon mesh from a Path3D curve to make a space-road, and everything looks great (yay!). What doesn’t work so great is physics bounding box calculations (boo!). You can access the site for reproducing this here - make sure to include the query string ?testDrive
unless you want to make your own route…
This screenshot shows the BB of the road for the testDrive route – you can see that because the path curves into the distance, the bounding box is far, far larger than the width of the road itself!
I’m using Ammo.js, FWIW. @RaananW @Cedric
Here’s the code that generates the route - it’s located here
calculateRouteParameters(routeData) {
let pathPoints = routeData.map(p => {
return (typeof p.position !== 'Vector3' ?
new Vector3(p.position.x, p.position.y, p.position.z) : p)
.scaleInPlace(7);
});
let path3d = new Path3D(pathPoints, new Vector3(0, 1, 0), false, false);
let curve = path3d.getCurve();
let displayLines = MeshBuilder.CreateLines("displayLines",
{ points: curve }, this.scene);
let pathA = [];
let pathB = [];
for (let i = 0; i < curve.length; i++) {
let p = curve[i];
let pA = new Vector3(p.x + 20, p.y, p.z + 20);
let pB = new Vector3(p.x - 20, p.y, p.z - 20);
pathA.push(pA);
pathB.push(pB);
}
this.path = path3d;
this.curve = curve;
return [pathB, curve, pathA];
}
So my question is three-fold:
- Is there something I’m doing (or not) that could cause or correct this?
- Is this a bug in the physics/BB computations?
- If the previous two are all nil, then what are some of my options to construct a BBB?
My thought is that if I had to, I suppose I could subdivide the road into multiple segments that are all more-or-less straight enough to have well-aligned bounding boxes, or I could convert the routeData into a height map and use DynamicTerrain instead of Ribbon (which is actually still using Ribbon internally lol!).
Both of those options involve no small amount of effort, so I’m hoping there’s a more simpler way to make the bounds work “correctly”.
Sorry for not having a PG, if we can determine that this isn’t something in my local setup I can try to isolate this into a PG if that is useful.
ed: yikes, maybe providing some directions might be helpful – SHIFT+ALT+I opens inspector