|
@@ -3,24 +3,68 @@ var BABYLON;
|
|
var MeshBuilder = (function () {
|
|
var MeshBuilder = (function () {
|
|
function MeshBuilder() {
|
|
function MeshBuilder() {
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * Creates a box mesh.
|
|
|
|
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
|
|
|
|
+ * The parameter "size" sets the size (float) of each box side (default 1).
|
|
|
|
+ * You can set some different box dimensions by using the parameters "width", "height" and "depth" (all by default have the same value than "size").
|
|
|
|
+ * You can set different colors and different images to each box side by using the parameters "faceColors" (an array of 6 Color3 elements) and "faceUV" (an array of 6 Vector4 elements).
|
|
|
|
+ * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
|
|
|
|
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
|
|
|
|
+ * Detail here : http://doc.babylonjs.com/tutorials/02._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.
|
|
|
|
+ */
|
|
MeshBuilder.CreateBox = function (name, options, scene) {
|
|
MeshBuilder.CreateBox = function (name, options, scene) {
|
|
var box = new BABYLON.Mesh(name, scene);
|
|
var box = new BABYLON.Mesh(name, scene);
|
|
var vertexData = BABYLON.VertexData.CreateBox(options);
|
|
var vertexData = BABYLON.VertexData.CreateBox(options);
|
|
vertexData.applyToMesh(box, options.updatable);
|
|
vertexData.applyToMesh(box, options.updatable);
|
|
return box;
|
|
return box;
|
|
};
|
|
};
|
|
|
|
+ /**
|
|
|
|
+ * Creates a sphere mesh.
|
|
|
|
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
|
|
|
|
+ * The parameter "diameter" sets the diameter size (float) of the sphere (default 1).
|
|
|
|
+ * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters "diameterX", "diameterY" and "diameterZ" (all by default have the same value than "diameter").
|
|
|
|
+ * The parameter "segments" sets the sphere number of horizontal stripes (positive integer, default 32).
|
|
|
|
+ * You can create an unclosed sphere with the parameter "arc" (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
|
|
|
|
+ * You can create an unclosed sphere on its height with the parameter "slice" (positive float, default1), valued between 0 and 1, what is the height ratio (longitude).
|
|
|
|
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
|
|
|
|
+ * Detail here : http://doc.babylonjs.com/tutorials/02._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.
|
|
|
|
+ */
|
|
MeshBuilder.CreateSphere = function (name, options, scene) {
|
|
MeshBuilder.CreateSphere = function (name, options, scene) {
|
|
var sphere = new BABYLON.Mesh(name, scene);
|
|
var sphere = new BABYLON.Mesh(name, scene);
|
|
var vertexData = BABYLON.VertexData.CreateSphere(options);
|
|
var vertexData = BABYLON.VertexData.CreateSphere(options);
|
|
vertexData.applyToMesh(sphere, options.updatable);
|
|
vertexData.applyToMesh(sphere, options.updatable);
|
|
return sphere;
|
|
return sphere;
|
|
};
|
|
};
|
|
|
|
+ /**
|
|
|
|
+ * Creates a plane polygonal mesh. By default, this is a disc.
|
|
|
|
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
|
|
|
|
+ * The parameter "radius" sets the radius size (float) of the polygon (default 0.5).
|
|
|
|
+ * The parameter "tessellation" sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc.
|
|
|
|
+ * You can create an unclosed polygon with the parameter "arc" (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
|
|
|
|
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
|
|
|
|
+ * Detail here : http://doc.babylonjs.com/tutorials/02._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.
|
|
|
|
+ */
|
|
MeshBuilder.CreateDisc = function (name, options, scene) {
|
|
MeshBuilder.CreateDisc = function (name, options, scene) {
|
|
var disc = new BABYLON.Mesh(name, scene);
|
|
var disc = new BABYLON.Mesh(name, scene);
|
|
var vertexData = BABYLON.VertexData.CreateDisc(options);
|
|
var vertexData = BABYLON.VertexData.CreateDisc(options);
|
|
vertexData.applyToMesh(disc, options.updatable);
|
|
vertexData.applyToMesh(disc, options.updatable);
|
|
return disc;
|
|
return disc;
|
|
};
|
|
};
|
|
|
|
+ /**
|
|
|
|
+ * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
|
|
|
|
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
|
|
|
|
+ * The parameter "radius" sets the radius size (float) of the icosphere (default 1).
|
|
|
|
+ * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters "radiusX", "radiusY" and "radiusZ" (all by default have the same value than "radius").
|
|
|
|
+ * The parameter "subdivisions" sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
|
|
|
|
+ * The parameter "flat" (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface.
|
|
|
|
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
|
|
|
|
+ * Detail here : http://doc.babylonjs.com/tutorials/02._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.
|
|
|
|
+ */
|
|
MeshBuilder.CreateIcoSphere = function (name, options, scene) {
|
|
MeshBuilder.CreateIcoSphere = function (name, options, scene) {
|
|
var sphere = new BABYLON.Mesh(name, scene);
|
|
var sphere = new BABYLON.Mesh(name, scene);
|
|
var vertexData = BABYLON.VertexData.CreateIcoSphere(options);
|
|
var vertexData = BABYLON.VertexData.CreateIcoSphere(options);
|
|
@@ -28,6 +72,19 @@ var BABYLON;
|
|
return sphere;
|
|
return sphere;
|
|
};
|
|
};
|
|
;
|
|
;
|
|
|
|
+ /**
|
|
|
|
+ * Creates a ribbon mesh.
|
|
|
|
+ * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
|
|
|
|
+ *
|
|
|
|
+ * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
|
|
|
|
+ * The parameter "pathArray" is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
|
|
|
|
+ * The parameter "closeArray" (boolean, default false) creates a seam between the first and the last paths of the path array.
|
|
|
|
+ * The parameter "closePath" (boolean, default false) creates a seam between the first and the last points of each path of the path array.
|
|
|
|
+ * The parameter "instance" is an instance of an existing Ribbon object to be updated with the passed "pathArray" parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
|
|
|
|
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
|
|
|
|
+ * Detail here : http://doc.babylonjs.com/tutorials/02._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.
|
|
|
|
+ */
|
|
MeshBuilder.CreateRibbon = function (name, options, scene) {
|
|
MeshBuilder.CreateRibbon = function (name, options, scene) {
|
|
var pathArray = options.pathArray;
|
|
var pathArray = options.pathArray;
|
|
var closeArray = options.closeArray;
|
|
var closeArray = options.closeArray;
|
|
@@ -108,18 +165,62 @@ var BABYLON;
|
|
return ribbon;
|
|
return ribbon;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+ /**
|
|
|
|
+ * Creates a cylinder or a cone mesh.
|
|
|
|
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
|
|
|
|
+ * The parameter "height" sets the height size (float) of the cylinder/cone (float, default 2).
|
|
|
|
+ * The parameter "diameter" sets the diameter of the top and bottom cap at once (float, default 1).
|
|
|
|
+ * The parameters "diameterTop" and "diameterBottom" overwrite the parameter "diameter" and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
|
|
|
|
+ * The parameter "tessellation" sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
|
|
|
|
+ * The parameter "subdivisions" sets the number of rings along the cylinder height (positive integer, default 1).
|
|
|
|
+ * The parameter "hasRings" (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
|
|
|
|
+ * The parameter "enclose" (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
|
|
|
|
+ * The parameter "arc" (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
|
|
|
|
+ * You can set different colors and different images to each box side by using the parameters "faceColors" (an array of n Color3 elements) and "faceUV" (an array of n Vector4 elements).
|
|
|
|
+ * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
|
|
|
|
+ * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
|
|
|
|
+ * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
|
|
|
|
+ * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
|
|
|
|
+ * If enclose is false, a ring surface is one element.
|
|
|
|
+ * If enclose true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
|
|
|
|
+ * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
|
|
|
|
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
|
|
|
|
+ * Detail here : http://doc.babylonjs.com/tutorials/02._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.
|
|
|
|
+ */
|
|
MeshBuilder.CreateCylinder = function (name, options, scene) {
|
|
MeshBuilder.CreateCylinder = function (name, options, scene) {
|
|
var cylinder = new BABYLON.Mesh(name, scene);
|
|
var cylinder = new BABYLON.Mesh(name, scene);
|
|
var vertexData = BABYLON.VertexData.CreateCylinder(options);
|
|
var vertexData = BABYLON.VertexData.CreateCylinder(options);
|
|
vertexData.applyToMesh(cylinder, options.updatable);
|
|
vertexData.applyToMesh(cylinder, options.updatable);
|
|
return cylinder;
|
|
return cylinder;
|
|
};
|
|
};
|
|
|
|
+ /**
|
|
|
|
+ * Creates a torus mesh.
|
|
|
|
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
|
|
|
|
+ * The parameter "diameter" sets the diameter size (float) of the torus (default 1).
|
|
|
|
+ * The parameter "thickness" sets the diameter size of the tube of the torus (float, default 0.5).
|
|
|
|
+ * The parameter "tessellation" sets the number of torus sides (postive integer, default 16).
|
|
|
|
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
|
|
|
|
+ * Detail here : http://doc.babylonjs.com/tutorials/02._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.
|
|
|
|
+ */
|
|
MeshBuilder.CreateTorus = function (name, options, scene) {
|
|
MeshBuilder.CreateTorus = function (name, options, scene) {
|
|
var torus = new BABYLON.Mesh(name, scene);
|
|
var torus = new BABYLON.Mesh(name, scene);
|
|
var vertexData = BABYLON.VertexData.CreateTorus(options);
|
|
var vertexData = BABYLON.VertexData.CreateTorus(options);
|
|
vertexData.applyToMesh(torus, options.updatable);
|
|
vertexData.applyToMesh(torus, options.updatable);
|
|
return torus;
|
|
return torus;
|
|
};
|
|
};
|
|
|
|
+ /**
|
|
|
|
+ * Creates a torus knot mesh.
|
|
|
|
+ * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
|
|
|
|
+ * The parameter "radius" sets the global radius size (float) of the torus knot (default 2).
|
|
|
|
+ * The parameter "radialSegments" sets the number of sides on each tube segments (positive integer, default 32).
|
|
|
|
+ * The parameter "tubularSegments" sets the number of tubes to decompose the knot into (positive integer, default 32).
|
|
|
|
+ * The parameters "p" and "q" are the number of windings on each axis (positive integers, default 2 and 3).
|
|
|
|
+ * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
|
|
|
|
+ * Detail here : http://doc.babylonjs.com/tutorials/02._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.
|
|
|
|
+ */
|
|
MeshBuilder.CreateTorusKnot = function (name, options, scene) {
|
|
MeshBuilder.CreateTorusKnot = function (name, options, scene) {
|
|
var torusKnot = new BABYLON.Mesh(name, scene);
|
|
var torusKnot = new BABYLON.Mesh(name, scene);
|
|
var vertexData = BABYLON.VertexData.CreateTorusKnot(options);
|
|
var vertexData = BABYLON.VertexData.CreateTorusKnot(options);
|