Creating A Sphere

Sphere

The created sphere has its origin at the center of the sphere. By using different values for diameterX, diameterY and diameterZ_ lead you create an ellipsoid.

MeshBuilder

Example :

const sphere = BABYLON.MeshBuilder.CreateSphere("sphere", options, scene); //scene is optional and defaults to the current scene
optionvaluedefault value
option
segments
value
(number) number of horizontal segments
default value
32
option
diameter
value
(number) diameter of the sphere
default value
1
option
diameterX
value
(number) diameter on X axis, overwrites diameter option
default value
diameter
option
diameterY
value
(number) diameter on Y axis, overwrites diameter option
default value
diameter
option
diameterZ
value
(number) diameter on Z axis, overwrites diameter option
default value
diameter
option
arc
value
(number) ratio of the circumference (latitude) between 0 and 1
default value
1
option
slice
value
(number) ratio of the height (longitude) between 0 and 1
default value
1
option
updatable
value
(boolean) true if the mesh is updatable
default value
false
option
sideOrientation
value
(number) side orientation
default value
DEFAULTSIDE
option
frontUVs
value
(Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set
default value
Vector4(0, 0, 1,1)
option
backUVs
value
(Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set
default value
Vector4(0, 0, 1,1)

Examples

Create a Sphere Create a Ellipsoid Create an Arc Create an Arc and Slice

Mesh

Usage :

const sphere = BABYLON.Mesh.CreateSphere("sphere", segments, diameter, scene);
const sphere = BABYLON.Mesh.CreateSphere("sphere", segments, diameter, scene, updatable, sideOrientation); //optional parameters after scene

It is only possible to create a sphere with this method, for an ellipsoid you need to use scaling.