Orientation and sizing of polyhedra


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.


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.



@JohnK might be able to help he is amazing with this :slight_smile:

Regarding size and rotation, you can still easily scale and rotate after creation Getting Started - Chapter 2 - Mesh Placement | Babylon.js Documentation

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.


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?

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

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?



It will give you a square base but you can scale in one direction to make it a rectangle.


This is a great help - and I’m learning a lot.


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

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).


Hence lines 30 and 31


Fantastic @JohnK
A wonderful solution.

Jedi Master” indeed.

Thank you for your kind help.

You rock @JohnK !!!