Creating A Box
Box Mesh
The created box has its origin at the center of the box, its width (x), height (y) and depth (z) are as given.
MeshBuilder.
Usage :
const box = BABYLON.MeshBuilder.CreateBox("box", options, scene); //scene is optional and defaults to the current scene
options property | value | default value |
---|---|---|
options property size | value (number) size of each box side | default value 1 |
options property height | value (number) height size, overwrites size option | default value size |
options property width | value (number) width size, overwrites size option | default value size |
options property depth | value (number) depth size, overwrites size option | default value size |
options property faceColors | value (Color4[]) array of 6 Color4, one per box face | default value Color4(1, 1, 1, 1) for each side |
options property faceUV | value (Vector4[]) array of 6 Vector4, one per box face | default value UVs(0, 0, 1, 1) for each side |
options property wrap | value (boolean) ( BJS 4.0 or >) when true all vertical sides (0, 1, 2, 3) will apply image textures upright | default value false |
options property topBaseAt | value (number) (BJS 4.0 or >) base of top touches side given 0, 1, 2, 3 | default value 1 |
options property bottomBaseAt | value (number) (BJS 4.0 or >) base of bottom touches side given 0, 1, 2, 3 | default value 0 |
options property updatable | value (boolean) true if the mesh is updatable | default value false |
options property sideOrientation | value (number) side orientation | default value DEFAULTSIDE |
options property frontUVs | value (Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set | default value Vector4(0,0, 1,1) |
options property backUVs | value (Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set | default value Vector4(0,0, 1,1) |
Examples
Cuboid: Create a Cuboid Face numbers, face 0 is on the positive z axis: Create a Box With Face Numbers
Mesh.
Usage
const box = BABYLON.Mesh.CreateBox("box", size, scene);const box = BABYLON.Mesh.CreateBox("box", size, scene, updatable, sideOrientation); //optional parameters after scene
It is only possible to create a cube with this method, for a cuboid you need to use scaling.