Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PolyhedronBuilder

Class containing static functions to help procedurally build meshes

Hierarchy

  • PolyhedronBuilder

Index

Methods

Static CreatePolyhedronSearch playground for CreatePolyhedron

  • CreatePolyhedron(name: string, options: { backUVs?: Vector4; custom?: any; faceColors?: Color4[]; faceUV?: Vector4[]; flat?: boolean; frontUVs?: Vector4; sideOrientation?: number; size?: number; sizeX?: number; sizeY?: number; sizeZ?: number; type?: number; updatable?: boolean }, scene?: Nullable<Scene>): Mesh
  • Creates a polyhedron mesh

    • The parameter type (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
    • The parameter size (positive float, default 1) sets the polygon size
    • You can overwrite the size on each dimension bu using the parameters sizeX, sizeY or sizeZ (positive floats, default to size value)
    • You can build other polyhedron types than the 15 embbeded ones by setting the parameter custom (polyhedronObject, default null). If you set the parameter custom, this overwrittes the parameter type
    • A polyhedronObject is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
    • You can set the color and the UV of each side of the polyhedron with the parameters faceColors (Color4, default (1, 1, 1, 1)) and faceUV (Vector4, default (0, 0, 1, 1))
    • To understand how to set faceUV or faceColors, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
    • The parameter flat (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, faceColors and faceUV are ignored
    • You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
    • If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters frontUVs and backUVs (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
    • The mesh can be set to updatable with the boolean parameter updatable (default false) if its internal geometry is supposed to change once created
    see

    https://doc.babylonjs.com/how_to/polyhedra_shapes

    Parameters

    • name: string

      defines the name of the mesh

    • options: { backUVs?: Vector4; custom?: any; faceColors?: Color4[]; faceUV?: Vector4[]; flat?: boolean; frontUVs?: Vector4; sideOrientation?: number; size?: number; sizeX?: number; sizeY?: number; sizeZ?: number; type?: number; updatable?: boolean }

      defines the options used to create the mesh

      • Optional backUVs?: Vector4
      • Optional custom?: any
      • Optional faceColors?: Color4[]
      • Optional faceUV?: Vector4[]
      • Optional flat?: boolean
      • Optional frontUVs?: Vector4
      • Optional sideOrientation?: number
      • Optional size?: number
      • Optional sizeX?: number
      • Optional sizeY?: number
      • Optional sizeZ?: number
      • Optional type?: number
      • Optional updatable?: boolean
    • Optional scene: Nullable<Scene>

      defines the hosting scene

    Returns Mesh

    the polyhedron mesh

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method