-
Notifications
You must be signed in to change notification settings - Fork 0
primitives
The primitives object provides a simple factory for generating basic mesh objects like boxes, spheres and cylinders.
var boxMesh = CubicVR.primitives.box({
size: 1.0,
material: material3,
uvmapper: uvcubic,
transform: (new CubicVR.Transform()).scale([1,2,3])
}).triangulateQuads().compile().clean();
Lathe will perform a lathe revolution for given points around the Y axis and generate the resulting faces.
Parameters:
- init - Object constructor:
-
points
: an array of points, format[ [x,y,z], [x,y,z], ... ]
to revolve. -
divisions
: number of divisions for the revolution. -
material
: (optional) a Material to apply to new geometry. -
mesh
: (optional) an existing Mesh to add the resulting object to. -
transform
: (optional) a Transform or a 4x4 matrix in an array of 16 floats, if supplied the new geometry will be transformed by it. -
uvmapper
: (optional) a UVMapper or a UVMapper object constructor to apply to new geometry.
-
Returns:
If mesh was supplied, it will return the original mesh instance. Otherwise a new Mesh will be created and returned.
Produces a simple 6 sided box mesh.
Parameters:
- init - Object constructor:
-
size
: The size of the box, resulting box issize * size * size
centered at the origin, default:1.0
. -
material
: (optional) a Material to apply to new geometry. -
mesh
: (optional) an existing Mesh to add the resulting object to. -
transform
: (optional) a Transform or a 4x4 matrix in an array of 16 floats, if supplied the new geometry will be transformed by it. -
uvmapper
: (optional) a UVMapper or a UVMapper object constructor to apply to new geometry.
-
Returns:
If mesh was supplied, it will return the original mesh instance. Otherwise a new Mesh will be created and returned.
Produces 2 quad faces on the X/Y axis facing back-to-back.
Parameters:
- init - Object constructor:
-
size
: The horizontal/vertical size of the plane, resulting plane issize * size
centered at the origin on the X/Y axis, default:1.0
. -
material
: (optional) a Material to apply to new geometry. -
mesh
: (optional) an existing Mesh to add the resulting object to. -
transform
: (optional) a Transform or a 4x4 matrix in an array of 16 floats, if supplied the new geometry will be transformed by it. -
uvmapper
: (optional) a UVMapper or a UVMapper object constructor to apply to new geometry.
-
Returns:
If mesh was supplied, it will return the original mesh instance. Otherwise a new Mesh will be created and returned.
Produces a sphere mesh with given radius and longitude/latitude, lathe-based.
Parameters:
- init - Object constructor:
-
radius
: radius of the sphere, default:1.0
-
lon
: number of divisions along the longitude (x) axis, default:24
. -
lat
: number of divisions along the latitude (y) axis, default:24
. -
material
: (optional) a Material to apply to new geometry. -
mesh
: (optional) an existing Mesh to add the resulting object to. -
transform
: (optional) a Transform or a 4x4 matrix in an array of 16 floats, if supplied the new geometry will be transformed by it. -
uvmapper
: (optional) a UVMapper or a UVMapper object constructor to apply to new geometry.
-
Returns:
If mesh was supplied, it will return the original mesh instance. Otherwise a new Mesh will be created and returned.
Produces a torus (or doughnut, Mmmm... doughnuts) with given inner/outer radius and longitude/latitude divisions, lathe-based.
Parameters:
- init - Object constructor:
-
innerRadius
: inner radius of the torus, default:0.75
. -
outerRadius
: outer radius of the torus, default:1.0
. -
lon
: number of divisions along the longitude (x) axis, default:24
. -
lat
: number of divisions along the latitude (y) axis, default:24
. -
material
: (optional) a Material to apply to new geometry. -
mesh
: (optional) an existing Mesh to add the resulting object to. -
transform
: (optional) a Transform or a 4x4 matrix in an array of 16 floats, if supplied the new geometry will be transformed by it. -
uvmapper
: (optional) a UVMapper or a UVMapper object constructor to apply to new geometry.
-
Returns:
If mesh was supplied, it will return the original mesh instance. Otherwise a new Mesh will be created and returned.
Produces a cone mesh with given base, lathe-based.
Parameters:
- init - Object constructor:
-
base
: base size of the cone, default1.0
. -
height
: height of the cone, default1.0
. -
lon
: number of divisions for the revolution, default24
. -
material
: (optional) a Material to apply to new geometry. -
mesh
: (optional) an existing Mesh to add the resulting object to. -
transform
: (optional) a Transform or a 4x4 matrix in an array of 16 floats, if supplied the new geometry will be transformed by it. -
uvmapper
: (optional) a UVMapper or a UVMapper object constructor to apply to new geometry.
-
Returns:
If mesh was supplied, it will return the original mesh instance. Otherwise a new Mesh will be created and returned.
Produce a cylinder mesh with given radius, height and divisions, lathe-based.
Parameters:
- init - Object constructor:
-
radius
: radius of cylinder, default:1.0
. -
height
: height of cylinder, default:1.0
. -
divisions
: number of divisions for the revolution, default24
. -
material
: (optional) a Material to apply to new geometry. -
mesh
: (optional) an existing Mesh to add the resulting object to. -
transform
: (optional) a Transform or a 4x4 matrix in an array of 16 floats, if supplied the new geometry will be transformed by it. -
uvmapper
: (optional) a UVMapper or a UVMapper object constructor to apply to new geometry.
-
Returns:
If mesh was supplied, it will return the original mesh instance. Otherwise a new Mesh will be created and returned.