I had originally intended to draw my own geometry from within BabylonJS but this has ultimately proven to be too complicated. Instead I have drawn what I want in a CAD package and exported as an STL.
The STL files are imported into Babylon by creating an
AssetsManager for each STL and then calling an
.addMeshTask to load the STL.
This is fine and the meshes appear in the browser but they do not appear positioned correctly. The top image is from the CAD package where I have reimported the STL files. As you can see they are coincident in certain places.
However, in Babylon the STLs do not appear correct relative to each other as you can see indicated by the arrows.
I have tried importing all the STLs into the same
AssetsManager but it doesn’t make any difference.
I can’t understand why the position would be out and I cant think of anything else to try… Has anyone got any suggestions why these are not loading correctly?
Did you check the STL file in another viewer ?
Yes I did - it is all coincident in every other package. Its very strange…
Furthermore, if I load the files differently in Babylon, for example via a CDN like so…
const rvBib = await BABYLON.SceneLoader.ImportMeshAsync("", "https://cdn.jsdelivr.net/gh/sydodman/Reference-Volumes/", "RV-BIB.stl", scene);
It then aligns as expected so it appears to be something to do with how I loaded the files via the assetmanager.
Can you repro in the playground ?
Hmmm interesting. I can’t. And I think I’ve spotted something which might have been incorrect…
If I load using the following in a local browser (i.e. with a local webserver and the files in the same folder as my .html page is it loads up misaligned)
var meshTask5 = rvFloorBody.addMeshTask("", "", "RV-FLOOR-BODY.stl");
If I use this in a playground it obviously doesn’t work as it doesn’t have access to the files. So instead I put the files in git and access via a CDN. The syntax changes to the following and it still loads up misaligned in my browser.
var meshTask5 = rvFloorBody.addMeshTask("", "https://cdn.jsdelivr.net/gh/sydodman/Reference-Volumes/", "RV-FLOOR-BODY.stl");
So I tried to copy all of this into a playground, hit load and nothing appears. I went back through the syntax and see that the syntax is missing an optional “”. If I add this second set of closed quoations into the code the files load and they are now aligned.
var meshTask5 = rvFloorBody.addMeshTask("", "", "https://cdn.jsdelivr.net/gh/sydodman/Reference-Volumes/", "RV-FLOOR-BODY.stl");
So, for some reason, with a missing set of optionals, the files load locally but not in quite the right position. In a playground, with the optionals missing nothing loads. If I add the optionals it now loads correctly both in a playground and in the local browser.
So Ive sort of fixed it but I dont really understand how or why? I hope this explanation makes sense. I appreciate it might be difficult to follow with out the PGs or local browser!
Glad you fixed it
But I am totally into this: