A module that draws meshes with a simple orbit based camera. This is useful for quickly making demos and live coding.
var shell =var meshshellshell
npm install mesh-viewer
The main viewer class is a modification of
gl-now and inherits all the same properties and methods as that.
var createShell =
var shell = createShell([options])
Creates a viewer. In addition to accepting all the arguments as gl-now, it also takes in the following arguments:
fovDefault fov for camera
zNearNear clip plane
zFarFar clip plane
meshColorDefault color for meshes
pointSizeDefault point size for meshes
useCellNormalsIf set, use flat shading for polygons
ambientDefault ambient light color * intensity
diffuseDefault diffuse light color * intensity
specularDefault specular light color * intensity
specularExponentDefault specular exponent
lightPositionDefault light position
Returns A mesh viewer shell
In addition to the events in
mesh-viewer has the following event:
This event is triggered after the viewer is initialized.
An instance of a
game-shell-orbit-camera that controls the viewing direction.
The FOV of the camera
The near z clip plane distance
The far z clip plane distance
var mesh = viewer.createMesh(params)
Creates a mesh object that can be drawn. This works the same as
params object accepts the following parameters:
cells(Required) An indexed list of vertices, edges and/or faces.
positions(Required) An array of positions for the mesh, encoded as arrays
vertexColorsA list of per vertex color attributes encoded as length 3 rgb arrays
cellColorsA list of per cell color attributes
meshColorA constant color for the entire mesh
vertexNormalsAn array of per vertex normals
cellNormalsAn array of per cell normals
useFacetNormalsA flag which if set to true forces cellNormals to be computed
pointSizesAn array of point sizes
pointSizeA single point size float
Returns A drawable mesh object
Mesh Object Methods
Draws the mesh object. Params has the same properties as in
Updates the mesh. Same conventions as before.
Destroys mesh releasing all resources.
(c) 2013 Mikola Lysenko. MIT License