API

Creating A Sphere

Sphere

The created sphere has its origin at the center of the sphere. Using different values for diameterX, diameterY, and diameterZ lets you create an ellipsoid.

MeshBuilder

Example :

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

Examples

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

Mesh

Usage :

import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";
const sphere = MeshBuilder.CreateSphere("sphere", { segments, diameter }, scene);

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