Yo @Deltakosh … Or @sebavan … Can you Pretty Please ask the person who makes the MeshBuilder, please, please, please… Make a CreateCapsule function that is similar to the CreateCylinder but with the capsule end pieces of course.
I mean for the sake of good clean code, I am using the other BABYLON.MeshBuilder.CreateXXXX functions… i would had to hate to HACK together some weird function that is not using the same constructs as the MeshBuilder is doing to create geometry… To be neat and clean there should really be a a CreateCapsule on the MeshBuilder…
Please
aWeirdo
September 6, 2020, 7:50pm
2
Interesting idea,
Can’t a cylinder and two half spheres be used?
but maybe the edges won’t align very well
Edit;
Out of curiosity, i did a ‘prototype’, https://playground.babylonjs.com/#BWHY4C#1
Pryme8
September 6, 2020, 10:06pm
3
Direct port of the Three.js method to make a capsule
Pryme8
September 6, 2020, 10:50pm
4
BabylonJS:master
← Pryme8:p8/CapsuleMesh
opened 10:50PM - 06 Sep 20 UTC
PR started… Ill try to get the comments and linting done after my meetings tonight.
1 Like
Thanks guys so much for following up with this
Cant wait for the PR to the MeshBuilder … For clean code sake
Pryme8
September 7, 2020, 4:40am
6
We shoulda had this for a hot min to be honest…
Yo @Pryme8 … So how do you use… i tried with this command and the capsule looks funny ?
var capsule = BABYLON.MeshBuilder.CreateCapsule("sphere", { tessellation:4, subdivisions:16, capSubdivisions:16, height: 2, radius: 0.5 }, scene);
Check out: https://www.babylonjs-playground.com/#K6M44R#1764
Looks all square
Yo @Pryme8 … Either is not working, or i dont have the right options… So what are the required options ???
Pryme8
September 11, 2020, 1:53am
8
Sweet… Yo @Pryme8 … Thanks so much for making this PR
Yo @Pryme8 … there is a slight issue with the height… That should be the TOTAL height… if i use height of 2 … that bapsule is taller than 2…
You must be using height for the cylinder portion only … So what is the cap height???
should it be if height = 2 … then cylinder portion should be (height - capHeight)
where height is the total height of the capsule… Right ???
Pryme8
September 11, 2020, 3:02am
11
Sure, most of this was not my code! I just converted it so anything like that might not have noticed yet. Ez fix though. I got you fam.
Not sure what the author had cap height for, Ill look now.
Pretty much the only thing I made was the orientation part and the conversion so keep ripping it apart so I can fix it!
UPDATE
I had a PR earlier but it failed the automatic tests, gotta replace the test image will make the new PR in the morning.
Yo @Pryme8 … Looks great… FYI … you left a console debug message in there
console.log("halfHeight", A);
1 Like
Pryme8
September 14, 2020, 2:37am
14
I’ll fix now good catch. Everything else working ok?