new Mesh()render3dMesh.js:206Create an empty mesh
const mesh = buildLathe([[0, -1], [1, 0], [0, 1]], 4); // octahedron
mesh.render(buildMatrix(vec3(0, 1, 0)), undefined, RED);Mesh - Triangles with positions, normals, uvs and colors, uploaded once and drawn by matrix
new Mesh()render3dMesh.js:206Create an empty mesh
const mesh = buildLathe([[0, -1], [1, 0], [0, 1]], 4); // octahedron
mesh.render(buildMatrix(vec3(0, 1, 0)), undefined, RED);bounds : Object|undefinedrender3dMesh.js:272Bounding box, for picking, measured with the radius
buffer : WebGLBuffer|undefinedrender3dMesh.js:225GPU vertex buffer, created by upload
bufferCount : numberrender3dMesh.js:230Indices in the GPU index buffer, three per triangle
colors : Array<Color>render3dMesh.js:222Vertex colors
dirty : booleanrender3dMesh.js:233The mesh changed and needs uploading again, set it yourself if you edit the arrays
doubleSided : booleanrender3dMesh.js:240Draw both sides, each lit as the side that is seen; off skips the faces pointing away, which is faster and right for closed shapes, the open builders like buildGrid and buildRibbon turn it on
dynamicDraw : booleanrender3dMesh.js:246The values change often but the shape never does, for a water surface or a cloth: set once, the mesh keeps its GPU layout and a dirty upload only rewrites the vertices into the buffer it has; the strip must keep the same points in the same order, a new point count asserts; the layout is decided by the first upload, so strip entries equal then stay one vertex and triangles with no area then stay dropped, set vertexKeys or give it distinct values at the start, not a flat grid of one color or points all in one place
indexBuffer : WebGLBuffer|undefinedrender3dMesh.js:228GPU index buffer, the triangles, created by upload
indices : Array<number>|undefinedrender3dMesh.js:252The mesh as an indexed triangle list instead of a strip: the arrays hold each vertex once and this says how they join, three vertex numbers per triangle, counter clockwise seen from the front like a strip's first triangle; addTriangles and the loaders fill it, toIndexed turns a strip mesh into this form
instanced : boolean|undefinedrender3dMesh.js:237Draw every use of this mesh in the opaque stage as one instanced call, undefined follows render3D.instancing
instanceData : Float32Array|undefinedrender3dMesh.js:267normals : Array<Vector3>render3dMesh.js:216Vertex normals
points : Array<Vector3>render3dMesh.js:213Vertex positions, in strip order or one per vertex of an indexed mesh
radius : numberrender3dMesh.js:269Bounding sphere radius around the origin, for culling and picking, computed by upload
uvs : Array<Vector2>render3dMesh.js:219Vertex texture coords, 0-1 across the tile
vertexCount : numberrender3dMesh.js:278Number of vertices in the mesh
vertexKeys : Int32Array|undefinedrender3dMesh.js:258Which strip entries are one vertex, set by a builder that knows, one whole number per entry with equal numbers meaning the same vertex; upload skips its search for them, then drops the keys, since an edit after that may tell the entries apart; adding geometry or recomputing normals drops them too
vertexLayout : Object|undefinedrender3dMesh.js:261addQuad(a, b, c, d, color, uvs) → Meshrender3dMesh.js:364Add a flat quad from four corners in loop order, counter clockwise seen from the front, a is the top left of the texture
addStrip(points, normals, uvs, colors) → Meshrender3dMesh.js:289Add a triangle strip, joined to the previous one by invisible flat triangles so one mesh holds many strips
addTriangles(points, indices, normals, uvs, colors) → Meshrender3dMesh.js:318Add triangles over their own vertices, the indexed form a model file comes in
points Array<Vector3>Each vertex once
indices Array<number>Three vertex numbers per triangle, into points
normals Vector3|Array<Vector3> optionalOne for all or one per point, default up
uvs Vector2|Array<Vector2> optionalOne for all or one per point, default zero
colors Color|Array<Color> optionalOne for all or one per point, default white
center() → Meshrender3dMesh.js:538Move the mesh so the center of its bounds is on the origin
combine(mesh, matrix, color) → Meshrender3dMesh.js:375Append another mesh transformed by a matrix, for building one shape out of several
computeNormals(smooth) → Meshrender3dMesh.js:570Derive normals from the triangles, of the strip or of the index list
smooth boolean optional, default falseRound the lighting across faces instead of giving each face a hard edge; flat normals on an indexed mesh give every corner its own vertex
computeRadius() → numberrender3dMesh.js:557Measure the bounding sphere around the origin into radius, called by upload
dispose()render3dMesh.js:775Delete the GPU buffer now, the CPU arrays stay so the mesh can be rendered again
fit(size) → Meshrender3dMesh.js:547Scale the mesh evenly so its largest extent is a size, for loaded models of unknown units
size number optional, default 1flipNormals() → Meshrender3dMesh.js:501Turn the mesh inside out so it is lit and drawn from within, for rooms and domes
getBounds() → Objectrender3dMesh.js:523Measure the axis aligned box around the vertices
getTriangles() → Objectrender3dMesh.js:695The mesh as an indexed triangle list, what upload sends to the GPU: the strip's real triangles over its distinct vertices, the joins between its pieces dropped and every triangle facing the way it did in the strip
intersect(mesh, matrix) → Meshrender3dMesh.js:467Returns a new mesh of only what is in both this mesh and the other, see subtract
mirror(axis) → Meshrender3dMesh.js:416Returns a new mesh: this one and its mirror image across the plane through the origin facing axis
axis Vector3 optionalFaces the mirror plane, vec3(1,0,0) mirrors across x
render(matrix, tileInfo, color)render3dMesh.js:771Draw the mesh with the current draw state, batched with its other uses in the opaque stage
matrix Matrix4|Vector3 optionalObject transform, or just a position to draw it at
tileInfo TileInfo|TextureInfo optionalTexture, mesh uvs map across the tile or the whole texture
color Color optionalTint
scaleUVs(scale) → Meshrender3dMesh.js:472Scale every uv, so a whole texture repeats across the mesh when its TextureInfo wraps
scale Vector2|numberRepeats across and up, a number for both
spin(count, axis) → Meshrender3dMesh.js:429Returns a new mesh of count copies of this one, each turned further around an axis through the origin
count numberCopies, spaced evenly around the whole turn
axis Vector3 optionalUp by default
subtract(mesh, matrix) → Meshrender3dMesh.js:461Returns a new mesh of this one with the other cut out of it, CSG with BSP trees
mesh MeshClosed, as the builders make them apart from the open ones like buildGrid
matrix Matrix4|Vector3 optionalPlaces the other mesh, or just a position to move it to
const wall = buildBox(vec3(4, 3, .5)).subtract(buildBox(vec3(1, 2, 1)), vec3(0, -.5, 0)); // a doorwaytoIndexed() → Meshrender3dMesh.js:341Turn a strip mesh into the indexed form, each distinct vertex once and the real triangles over them, in place
transform(matrix) → Meshrender3dMesh.js:484Move, turn or scale every vertex in place, normals follow along
union(mesh, matrix) → Meshrender3dMesh.js:443Returns a new mesh of everything in this mesh or the other, see subtract
upload() → Meshrender3dMesh.js:646Pack the vertices and create the GPU buffer, called automatically by render