The Wonderland Engine instance being used
Readonly
engineThe Wonderland Engine instance being used
The list of all triangles in this manifold. Note that this array might be detached from the builder and replaced with a new array. It is safe to use between operations, but when doing some operations such as subDivide4, a new array will be created.
Check if all triangles in the MeshBuilder are connected to each-other.
True if all triangles are connected.
Get the number of triangles in this MeshBuilder. Equivalent to getting the length of triangles.
Applies smooth normals to all vertices that have no normals set (0,0,0). Smooth normals are calculated for each vertex by getting all triangles connected to the vertex (the vertex star), and making smoothing groups by checking the angle between all of those triangles. Triangles that have similar angles will contribute to the average normal. Triangles are expected to have their helpers set. If not, make sure to call setTriangleHelpers (note that addTriangle already does this).
Maximum angle, in radians, between 2 triangles for them to be considered part of the same smoothing group for a vertex
If true, then all vertex normals will be reset to (0,0,0) before applying the modifier
Defaults to true. If true, then smoothed vertices will have their tangents merged.
Add triangles that make up a sub-divided quad. Adding a quad with 1 sub-division will create 2 new triangles, while adding a quad with 2 sub-divisions will create 8 triangles (4 sub-quads, with 2 triangles each).
All edges in generated triangles will be connected, except the border edges; new triangles will not be connected to triangles already present in the builder.
Top-left quad position.
Top-right quad position.
Bottom-left quad position.
Bottom-right quad position.
The material to use for the quad, as a numeric ID.
True by default. If true, then vertex tangents will be generated for each triangle. Tangents point from left to right, and have a w component of 1.
The amount of horizontal and vertical subdivisions to use. 1 by default (only one square). If there are 2 sub-divisions there will be 4 squares, 3 sub-divisions there will be 9 squares, etc...
Optional
tlUV: vec2Top-left quad texture coordinate.
Optional
trUV: vec2Top-right quad texture coordinate.
Optional
blUV: vec2Bottom-left quad texture coordinate.
Optional
brUV: vec2Bottom-right quad texture coordinate.
Similar to addSubdivQuad, but also records edges and triangles to given lists so that they can be used with autoConnectEdges.
The list of edges that will be connected to the list of triangles. Edges will be appended to this list if the edgeMask is set to a non-zero value.
The list of triangles that will be connected to the list of edges. Triangles will be appended to this list if the connectableTriMask is set to a non-zero value.
A 4-bit bitmask with the edges that will be added to the list of edges. The bits, from most significant to least significant, are: left edge, right edge, top edge, bottom edge.
A 4-bit bitmask with the triangles that will be added to the list of connectable triangles. The bits, from most significant to least significant, are: left edge triangles, right edge triangles, top edge triangles, bottom edge triangles.
Top-left quad position.
Top-right quad position.
Bottom-left quad position.
Bottom-right quad position.
The material to use for the quad, as a numeric ID.
True by default. If true, then vertex tangents will be generated for each triangle. Tangents point from left to right, and have a w component of 1.
Optional
tlUV: vec2Top-left quad texture coordinate.
Optional
trUV: vec2Top-right quad texture coordinate.
Optional
blUV: vec2Bottom-left quad texture coordinate.
Optional
brUV: vec2Bottom-right quad texture coordinate.
Pushes a new triangle to the end of the triangles array. Helpers are set to their index on the triangles array.
Optional
extraAttributes: ExtraTriangleAttributesSimilar to addTriangle, but normals are not set (kept as 0,0,0).
Optional
extraAttributes: ExtraTriangleAttributesNoNormalsCalls autoConnectAllEdges with all the triangles in this builder.
Create a list of Wonderland Engine meshes and a manifold from the current list of triangles. Helpers are expected to be set. If not, make sure to call setTriangleHelpers.
Output meshes are optimised by merging vertices with the same vertex data, via indexing.
Maps each material index to a Wonderland Engine material. Triangles with different material will be put in separate meshes, but in the same manifold. A null material is equivalent to the material being missing in the material map. Materials missing from the material map will use null as the material so they can be replaced later with a fallback material.
Maps a hint to a material. The null key represents the default hint. A hint decides which mesh attribute to generate.
Optional
failOnMissing: booleanIf this is true and a hinted mesh attribute fails to be gotten, an error will be thrown.
Optional
generateManifold: trueTrue by default. If true, a manifold and a submesh map will also be generated, otherwise, these will be null. Note than if a manifold is generated, then the triangles must form a 2-manifold surface, but if a manifold is not generated, then even a triangle soup is supported.
Private
finalizeInternal function. Creates a submesh
Make UVs for an equirectangular projection. The mapping will always be heavily distorted near the poles as it is impossible to do equirectangular projections properly without custom shaders.
Generally, more subdivisions lead to better mappings, but this has diminishing returns.
Rotate each triangle in the MeshBuilder by a given rotation.
The quaternion to rotate by.
Should the normals of each triangle be rotated? Defaults to true.
Should the tangents of each triangle be rotated? Defaults to true.
Private
smoothenInternal method. Makes smooth vertex normals given helper values.
Sub-divide each triangle in the MeshBuilder into 4 triangles, where the midpoints of each edge are used as the corners of the new triangles. Replaces triangles with a new array instead of modifying it in-place.
Transform each triangle in the MeshBuilder by a given transformation matrix.
The transformation matrix to transform positions by.
Optional
normalMatrix: mat3The transformation matrix to transform normals and tangents by. Will be ignored if normals and tangents aren't transformed. If not supplied and normals or tangents are to be transformed, then it will be automatically created from the position transform matrix.
Should the normals of each triangle be transformed? Defaults to true.
Should the tangents of each triangle be transformed? Defaults to true.
Modify all positions on the mesh by a given function. Other vertex attributes are not modified.
The transformation function to use for warping each vertex. Should return a new position given an X, Y and Z component of the original triangle.
Generated using TypeDoc
A helper class for easily creating meshes, with connected triangles.