import Mesh from '@mobilizing/library/js/Mobilizing/renderer/3D/three/shape/Mesh.js'
Mesh
Direct Subclass:
A Mesh is the aggregation of a geomtery, made of vertices (Vector3 Array), texture coordinates (or uv, Vector2 Array), vertexColor (Color Array) and various methods to create and modify 3D objects that have a material (see {{#crossLink "Material"}}{{/crossLink}}) and a transform (see {{#crossLink "Transform"}}{{/crossLink}}).
Static Method Summary
Static Public Methods | ||
public static | generateStrokeMesh(mesh: Mesh, inflateValue: Number): Mesh Static Utils to generate the stroke Mesh from a given shape | |
public static | generateStrokeShape(mesh: Mesh, inflateValue: Number): * Static Utils to generate the stroke for the given vertices with the given stroke width | |
public static | geometryIsCW(geometry: Geometry): Boolean Static Utils to check the direction of a geometry (ccw o cw) |
Constructor Summary
Public Constructor | ||
public | constructor(params: Object) Construct an empty and unfinished Mesh for which a geometry must be constructed. |
Member Summary
Public Members | ||
public | events: * | |
public | geometry: * | |
public | ||
public | ||
public | ||
public | ||
public | indices: *[] | |
public | material: * | |
public | maxVertices: * | |
public | name: * | |
public | ||
public | rootName: * | |
public | transform: * | |
public | type: * | |
public | ||
public |
Private Members | ||
private | _mesh: * |
Method Summary
Public Methods | ||
public | attachMaterial(material: Material) Attach the material to this mesh. | |
public | clone(): * deep clone this Mesh return {Mesh} a new clone (copy) of this Mesh in a new Mesh object | |
public | compute Face and Vertex Normals for the current geometry | |
public | Call this method to construct a custom mesh | |
public | Erase this mesh's geometry and material from memory | |
public | generateFillMesh(vertices: *) Generate the mesh for the given vertices and generates flat uvs for it. | |
public | Generate the flat uvs for this mesh. | |
public | genereate a mesh from already made geometry and material | |
public | getBoundingBox(force: Boolean): Object Compute and returns the bounding box of the current geometry or Node, which is an object made of 2 Vector3. | |
public | getBoundingSphere(force: Boolean): Object Compute and returns the bounding sphere of the current geometry or Node, which is an object with a radius : | |
public | Returns the center of the geometry (vertices) based on boundingbox | |
public | Shortcut for getSize().y | |
public | Shortcut for getSize().z | |
public | getNativeGeometry(): * | |
public | getNativeObject(): * | |
public | Returns the size of the geometry (vertices) based on boundingbox | |
public | Get the UV of this mesh geometry | |
public | Get the vertexColors of this mesh geometry's vertices | |
public | getVertices(): Array Get the vertices of this mesh geometry | |
public | Get the visibility of this mesh | |
public | Shortcut for getSize().x | |
public | Generate Float32Array and BufferAttribute for this geometry | |
public | pushNormal(n1: Vector2, n2: Vector2, n3: Vector2) Adds a Normal to the current geometry | |
public | Adds a Quad to the current geometry | |
public | pushTriangle(v1: Vector3, v2: Vector3, v3: Vector3) Adds a triangle to the current geometry | |
public | Adds a UV to the current geometry | |
public | pushVertex(v: Vector3) Adds a vertex to the current geometry | |
public | convinient method to reverse this Mesh geometry's normals | |
public | setCastShadow(enabled: Boolean) setCastShadow | |
public | Defines the position of the geometry's center (NOT the transform!). | |
public | setEventEmitterTrigger(scope: *, eventType: *) | |
public | setMaterial(material: Material | String) Sets this Mesh material. | |
public | setMaxVertices(val: *) | |
public | setReceiveShadow(enabled: Boolean) setReceiveShadow | |
public | setRootName(name: String) | |
public | setRotationX(value: float) Set the rotation around x axis of the vertices (not the transform!) | |
public | setRotationY(value: float) Set the rotation around y axis of the vertices (not the transform!) | |
public | setRotationZ(value: float) Set the rotation around z axis of the vertices (not the transform!) | |
public | Set the scale of the geometry (vertices) - this is not like scaling the transform. | |
public | setTranslation(value: float, value: float, value: float) Set the translation along all axis of the vertices (not the transform!) | |
public | Set the UV of this mesh geometry | |
public | setVertex(index: *, vertex: *) | |
public | setVertexColors(colors: Array<Color>) Set the vertexColors of this mesh geometry's vertices | |
public | setVertices(vertices: Object) Set the vertices of this mesh geometry | |
public | setVisible(value: Boolean) Set the visibility of this mesh |
Private Methods | ||
private | Updates this mesh material |
Static Public Methods
public static generateStrokeMesh(mesh: Mesh, inflateValue: Number): Mesh source
Static Utils to generate the stroke Mesh from a given shape
Return:
Mesh | the resulting Mesh |
Public Constructors
public constructor(params: Object) source
Construct an empty and unfinished Mesh for which a geometry must be constructed. Once filled with vertices, constructMesh method must be called, or a method generating a complete Mesh must be used (i.e generateFillMesh)
Params:
Name | Type | Attribute | Description |
params | Object | Parameters object, given by the constructor. | |
params.name | String | The name of the primitive to create, can be one of the listed names in this class description. | |
params.material | String |
| The name of the material to attach to the created primitive, can be one of : lambert, basic, phong. |
params.geometry | Object |
| An already existing geometry |
params.Number | Number |
| maxVertices for dynamically defined geometry, we must use a bufferArray already filled to add vertices |
Public Members
public events: * source
public geometry: * source
public geometryColorAttributes: * source
public geometryNormalAttributes: * source
public geometryUVAttributes: * source
public geometryVerticesAttributes: * source
public indices: *[] source
public material: * source
public maxVertices: * source
public name: * source
public rootName: * source
public transform: * source
public type: * source
Private Members
private _mesh: * source
Public Methods
public attachMaterial(material: Material) source
Attach the material to this mesh. The material must have been created before calling this method
Params:
Name | Type | Attribute | Description |
material | Material |
public clone(): * source
deep clone this Mesh return {Mesh} a new clone (copy) of this Mesh in a new Mesh object
Return:
* |
public computeNormals() source
compute Face and Vertex Normals for the current geometry
public constructMesh() source
Call this method to construct a custom mesh
public erase(recursive: Boolean) source
Erase this mesh's geometry and material from memory
Params:
Name | Type | Attribute | Description |
recursive | Boolean | if true, will erase all the children recursively |
public generateFillMesh(vertices: *) source
Generate the mesh for the given vertices and generates flat uvs for it. Usefull for 2D shapes
Params:
Name | Type | Attribute | Description |
vertices | * |
public generateFlatUVs() source
Generate the flat uvs for this mesh.
public genereateMesh() source
genereate a mesh from already made geometry and material
public getBoundingBox(force: Boolean): Object source
Compute and returns the bounding box of the current geometry or Node, which is an object made of 2 Vector3.
Params:
Name | Type | Attribute | Description |
force | Boolean | force computation |
Return:
Object | boundingBox object {min: new Vector3, max: new Vector3} |
public getBoundingSphere(force: Boolean): Object source
Compute and returns the bounding sphere of the current geometry or Node, which is an object with a radius :
Params:
Name | Type | Attribute | Description |
force | Boolean | force computation |
Return:
Object | boundingSphere object {radius: number} |
public getCenter(): Vector3 source
Returns the center of the geometry (vertices) based on boundingbox
Return:
Vector3 | vector3 of the current geometry center |
public getNativeGeometry(): * source
Return:
* | the Three.js native geometry of this mesh |
public getNativeObject(): * source
Return:
* | the Three.js native objects used in this class |
public getSize(): Vector3 source
Returns the size of the geometry (vertices) based on boundingbox
Return:
Vector3 | vector3 sizes of the current geometry |
public getUVs(index: integer): Array source
Get the UV of this mesh geometry
Params:
Name | Type | Attribute | Description |
index | integer | of the UV to get |
Return:
Array | uvs |
public getVertices(): Array source
Get the vertices of this mesh geometry
Return:
Array | vertices an array of Vector3 representing vertices |
public getVisible(): Boolean source
Get the visibility of this mesh
Return:
Boolean | value visible or not |
public makeGeometryBuffers() source
Generate Float32Array and BufferAttribute for this geometry
public pushNormal(n1: Vector2, n2: Vector2, n3: Vector2) source
Adds a Normal to the current geometry
public pushQuad(v1: Vector3, v2: Vector3, v3: Vector3, v4: Vector3) source
Adds a Quad to the current geometry
public pushTriangle(v1: Vector3, v2: Vector3, v3: Vector3) source
Adds a triangle to the current geometry
public pushVertex(v: Vector3) source
Adds a vertex to the current geometry
Params:
Name | Type | Attribute | Description |
v | Vector3 | vertex to add |
public reverseNormals() source
convinient method to reverse this Mesh geometry's normals
public setCastShadow(enabled: Boolean) source
setCastShadow
Params:
Name | Type | Attribute | Description |
enabled | Boolean |
public setCenter(x: number, y: number, z: number) source
Defines the position of the geometry's center (NOT the transform!).
public setEventEmitterTrigger(scope: *, eventType: *) source
Params:
Name | Type | Attribute | Description |
scope | * | ||
eventType | * |
public setMaterial(material: Material | String) source
Sets this Mesh material. Be warned that this method requiers to build a new mesh, so it can be slow on update. Better use it in setup.
public setMaxVertices(val: *) source
Params:
Name | Type | Attribute | Description |
val | * |
public setReceiveShadow(enabled: Boolean) source
setReceiveShadow
Params:
Name | Type | Attribute | Description |
enabled | Boolean |
public setRotationX(value: float) source
Set the rotation around x axis of the vertices (not the transform!)
Params:
Name | Type | Attribute | Description |
value | float | Rotation value in degree |
public setRotationY(value: float) source
Set the rotation around y axis of the vertices (not the transform!)
Params:
Name | Type | Attribute | Description |
value | float | Rotation value in degree |
public setRotationZ(value: float) source
Set the rotation around z axis of the vertices (not the transform!)
Params:
Name | Type | Attribute | Description |
value | float | Rotation value in degree |
public setScale(number|Vector3|Vector2: float | Vector3 | Vector2, Number: float, Number: float) source
Set the scale of the geometry (vertices) - this is not like scaling the transform. Shouldn't be done in loop. Polymorphic : can take various agruments of various types. Possible arguments number is 1, 2 or 3.
Params:
Name | Type | Attribute | Description |
number|Vector3|Vector2 | float | Vector3 | Vector2 | Value for the new scale of the geometry. If a Vector3 is given, its x, y, z will be used for the scale x, y, z. If a Vector2 is given, its x, y will be used for the scale x and y, but z will be 1. If a number is given, it will be the scale x. | |
Number | float | Value for the new y scale of the geometry. | |
Number | float | Value for the new z scale of the geometry. |
public setTranslation(value: float, value: float, value: float) source
Set the translation along all axis of the vertices (not the transform!)
Params:
Name | Type | Attribute | Description |
value | float | x value | |
value | float | y value | |
value | float | z value |
public setUVs(index: integer, uvs: Array) source
Set the UV of this mesh geometry
Params:
Name | Type | Attribute | Description |
index | integer | ||
uvs | Array |
public setVertex(index: *, vertex: *) source
Params:
Name | Type | Attribute | Description |
index | * | ||
vertex | * |
public setVertexColors(colors: Array<Color>) source
Set the vertexColors of this mesh geometry's vertices
public setVertices(vertices: Object) source
Set the vertices of this mesh geometry
Params:
Name | Type | Attribute | Description |
vertices | Object | And Array of Vector3 (points) |
public setVisible(value: Boolean) source
Set the visibility of this mesh
Params:
Name | Type | Attribute | Description |
value | Boolean | visible or not |
Private Methods
private updateMaterial() source
Updates this mesh material