evorob
September 23, 2021, 2:44pm
1
Hi,
I’m a newbie to BablyonJS (and 3D in general)
I have found Polyhedron type 8 - A square pyramid - to be the ideal shape that I need
But I cannot work out its default orientation.
https://playground.babylonjs.com/#V4I8KZ#1
Nor can I fathom how to resize it - which particular properties does the sizeX, sizeY and sizrZ refer?
Essentially I’d like to be able to get (1) the pyramid into a known orientation (E.g. one base edge on a cardinal axis)
and (2) resize it based on the dimensions of the pyramid that I need.
then (3) rotate it about space as required.
Any pointers greatly appreciated.
Thanks
R
sebavan
September 23, 2021, 3:45pm
2
@JohnK might be able to help he is amazing with this
Regarding size and rotation, you can still easily scale and rotate after creation Getting Started - Chapter 2 - Mesh Placement | Babylon.js Documentation
evorob
September 23, 2021, 4:23pm
3
Thank you,
With sizing, I’m not sure what the sizing parameters pertain to… I’ve experimented and as far as I can guess: the X,Y, Z are not fundamental properties of the pyramid, but maybe the sides of an encapsulating bounding box cube, but the pyramid is not within this bounding box orthogonally.
EDIT:
I’ve stumbled upon the inspector and have found this bounding box and the pyramid within.
is it possible to build the pyramid orthoganel to its bounding box?
JohnK
September 23, 2021, 5:11pm
4
Scaling is in reference to the world axes not those of the pyramid.
As the pyramid is a relatively simple shape the easiest way to get what you want is to do it using a cylinder Creating A Cylinder | Babylon.js Documentation
Set diameterTop to zero, diameterBottom to diagonal distance of square you need, height to required height and tessellation to 4.
Computer has gone down and on mobile so cannot do a playground to help further.
1 Like
evorob
September 23, 2021, 5:35pm
5
John,
Thank you
I’ll read up on what that scaling means
Sadly, i need a pyramid with a rectangular base. Whilst a really smart solution to use the cylinder, I think it will only give me a regular base.
Thanks for the pointers.
Do you know how polygons are built from within the bounding box?
Thanks
Rob
JohnK
September 23, 2021, 6:18pm
6
It will give you a square base but you can scale in one direction to make it a rectangle.
2 Likes
evorob
September 24, 2021, 9:56am
7
Thanks,
This is a great help - and I’m learning a lot.
https://playground.babylonjs.com/#C8QNA5
But with tessellation: 4
the scaling works across the resulting vertices not the edges, and so the base is a rhombus not a rectangle.
I’m not sure if there is a way out of this.
Thanks for the help
JohnK
September 24, 2021, 12:28pm
8
Need a couple of more steps.
The construction of the square pyramid places the diagonal along the x and z axes. Rotating by 45 degs aligns the mesh rendering but not the underlying structure. Baking the rotation changes the underlying structure (ie resets the vertex positions).
https://playground.babylonjs.com/#C8QNA5#1
Hence lines 30 and 31
2 Likes
evorob
September 24, 2021, 12:34pm
9
Fantastic @JohnK
A wonderful solution.
“Jedi Master ” indeed.
Thank you for your kind help.