Repository

Mesh

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

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

Construct an empty and unfinished Mesh for which a geometry must be constructed.

Member Summary

Public Members
public

events: *

public
public
public

name: *

public
public
public

type: *

Private Members
private

_mesh: *

Method Summary

Public Methods
public

Attach the material to this mesh.

public

Clears this mesh's geometry, that is vertices, faces and faceVertexUvs

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

Compute and returns the bounding box of the current geometry or Node, which is an object made of 2 Vector3.

public

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

Compute the intersection points between a plane and a mesh !Works ONLY if this mesh is "plane" primitive made

public
public
public

Returns the size of the geometry (vertices) based on boundingbox

public

getUVs(index: integer): Array

Get the UV of this mesh geometry

public

Get the vertexColors of this mesh geometry's vertices

public

Get the vertices of this mesh geometry

public

Get the visibility of this mesh

public

pushFace(i1: Integer, i2: Integer, i3: Integer): *

Adds a face to the current geometry

public

Adds a UV to the current geometry

public

pushQuad(v1: Vector3, v2: Vector3, v3: Vector3, v4: Vector3, uv1: Vector2, uv2: Vector2, uv3: Vector2, uv3: Vector2)

Adds a Quad to the current geometry

public

Adds a triangle to the current geometry

public

pushUV(uv1: Vector2, uv2: Vector2, uv3: Vector2)

Adds a UV to the current geometry

public

Adds a vertex to the current geometry

public

convinient method to reverse this Mesh geometry's normals

public

setCastShadow

public

Defines the position of the geometry's center (NOT the transform!).

public

setEventEmitterTrigger(scope: *, eventType: *)

public

setFaces(faces: *)

public

Sets this Mesh material.

public

setReceiveShadow

public
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

setScale(number|Vector3|Vector2: float | Vector3 | Vector2, Number: float, Number: float)

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

setUVs(index: integer, uvs: Array)

Set the UV of this mesh geometry

public

Set the vertexColors of this mesh geometry's vertices

public

setVertices(vertices: Object)

Set the vertices of this mesh geometry

public

Set the visibility of this mesh

public

updateMesh

public

updateStroke(inflateValue: Number)

Utils to regenerate the stroke Mesh when already existing

Private Methods
private

getUVFromIntersectionPoint

private

setPointOfIntersection(line: Object, plane: Object, intersectionPoint: Object): Object

setPointOfIntersection

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

Params:

NameTypeAttributeDescription
meshMesh

to use as a base to get vertices

inflateValueNumber

stroke width

Return:

Mesh

the resulting Mesh

public static generateStrokeMeshFromShape(shape: Shape): Mesh source

Static Utils to generate the stroke Mesh from a given shape

Params:

NameTypeAttributeDescription
shapeShape

Return:

Mesh

the resulting Mesh

public static generateStrokeShape(mesh: Mesh, inflateValue: Number): * source

Static Utils to generate the stroke for the given vertices with the given stroke width

Params:

NameTypeAttributeDescription
meshMesh

to use as a base to get vertices

inflateValueNumber

stroke width

Return:

*

(Shape) a Three.js Shape to make a geometry from

public static geometryIsCW(geometry: Geometry): Boolean source

Static Utils to check the direction of a geometry (ccw o cw)

Params:

NameTypeAttributeDescription
geometryGeometry

Three.js geometry

Return:

Boolean

is CW or not

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:

NameTypeAttributeDescription
paramsObject

Parameters object, given by the constructor.

params.nameString

The name of the primitive to create, can be one of the listed names in this class description.

params.materialString
  • optional
  • default: "phong"

The name of the material to attach to the created primitive, can be one of : lambert, basic, phong.

params.geometryObject
  • optional
  • default: undefined

An already existing geometry

Public Members

public events: * source

public geometry: * source

public material: * 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:

NameTypeAttributeDescription
materialMaterial

public clear() source

Clears this mesh's geometry, that is vertices, faces and faceVertexUvs

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() source

Erase this mesh's geometry and material from memory

public generateFillMesh(vertices: *) source

Generate the mesh for the given vertices and generates flat uvs for it. Usefull for 2D shapes

Params:

NameTypeAttributeDescription
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(): Object source

Compute and returns the bounding box of the current geometry or Node, which is an object made of 2 Vector3.

Return:

Object

boundingBox object {min: new Vector3, max: new Vector3}

public getBoundingSphere(): Object source

Compute and returns the bounding sphere of the current geometry or Node, which is an object with a radius :

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 getIntersectionsPoints(mesh: Mesh): Array source

Compute the intersection points between a plane and a mesh !Works ONLY if this mesh is "plane" primitive made

Params:

NameTypeAttributeDescription
meshMesh

the mesh to use for the intersections computation

Return:

Array

an array of object as {vertex: Vector3, uv: Vector2};

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:

NameTypeAttributeDescription
indexinteger

of the UV to get

Return:

Array

uvs

public getVertexColors(): Array<Color> source

Get the vertexColors of this mesh geometry's vertices

Return:

Array<Color>

colors

public getVertices(): Object source

Get the vertices of this mesh geometry

Return:

Object

vertices

public getVisible(): Boolean source

Get the visibility of this mesh

Return:

Boolean

value visible or not

public pushFace(i1: Integer, i2: Integer, i3: Integer): * source

Adds a face to the current geometry

Params:

NameTypeAttributeDescription
i1Integer

Face Index to add

i2Integer

Face Index to add

i3Integer

Face Index to add

Return:

*

public pushNormal(n1: Vector2, n2: Vector2, n3: Vector2) source

Adds a UV to the current geometry

Params:

NameTypeAttributeDescription
n1Vector2

n coordinates to add

n2Vector2

n coordinates to add

n3Vector2

n coordinates to add

public pushQuad(v1: Vector3, v2: Vector3, v3: Vector3, v4: Vector3, uv1: Vector2, uv2: Vector2, uv3: Vector2, uv3: Vector2) source

Adds a Quad to the current geometry

Params:

NameTypeAttributeDescription
v1Vector3

vertex coordinates of the Quad

v2Vector3

vertex coordinates of the Quad

v3Vector3

vertex coordinates of the Quad

v4Vector3

vertex coordinates of the Quad

uv1Vector2

uv coordinates to add

uv2Vector2

uv coordinates to add

uv3Vector2

uv coordinates to add

uv3Vector2

uv coordinates to add

public pushTriangle(v1: Vector3, v2: Vector3, v3: Vector3) source

Adds a triangle to the current geometry

Params:

NameTypeAttributeDescription
v1Vector3

vertex coordinates of the triangle

v2Vector3

vertex coordinates of the triangle

v3Vector3

vertex coordinates of the triangle

public pushUV(uv1: Vector2, uv2: Vector2, uv3: Vector2) source

Adds a UV to the current geometry

Params:

NameTypeAttributeDescription
uv1Vector2

uv coordinates to add

uv2Vector2

uv coordinates to add

uv3Vector2

uv coordinates to add

public pushVertex(v: Vector3) source

Adds a vertex to the current geometry

Params:

NameTypeAttributeDescription
vVector3

vertex to add

public reverseNormals() source

convinient method to reverse this Mesh geometry's normals

public setCastShadow(enabled: Boolean) source

setCastShadow

Params:

NameTypeAttributeDescription
enabledBoolean

public setCenter(x: number, y: number, z: number) source

Defines the position of the geometry's center (NOT the transform!).

Params:

NameTypeAttributeDescription
xnumber

x coordinate

ynumber

y coordinate

znumber

z coordinate

public setEventEmitterTrigger(scope: *, eventType: *) source

Params:

NameTypeAttributeDescription
scope*
eventType*

public setFaces(faces: *) source

Params:

NameTypeAttributeDescription
faces*

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.

Params:

NameTypeAttributeDescription
materialMaterial | String

the new material to set (if String used, one of "phong", "lambert", "basic")

public setReceiveShadow(enabled: Boolean) source

setReceiveShadow

Params:

NameTypeAttributeDescription
enabledBoolean

public setRootName(name: String) source

Params:

NameTypeAttributeDescription
nameString

public setRotationX(value: float) source

Set the rotation around x axis of the vertices (not the transform!)

Params:

NameTypeAttributeDescription
valuefloat

Rotation value in degree

public setRotationY(value: float) source

Set the rotation around y axis of the vertices (not the transform!)

Params:

NameTypeAttributeDescription
valuefloat

Rotation value in degree

public setRotationZ(value: float) source

Set the rotation around z axis of the vertices (not the transform!)

Params:

NameTypeAttributeDescription
valuefloat

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:

NameTypeAttributeDescription
number|Vector3|Vector2float | 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.

Numberfloat

Value for the new y scale of the geometry.

Numberfloat

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:

NameTypeAttributeDescription
valuefloat

x value

valuefloat

y value

valuefloat

z value

public setUVs(index: integer, uvs: Array) source

Set the UV of this mesh geometry

Params:

NameTypeAttributeDescription
indexinteger
uvsArray

public setVertexColors(colors: Array<Color>) source

Set the vertexColors of this mesh geometry's vertices

Params:

NameTypeAttributeDescription
colorsArray<Color>

public setVertices(vertices: Object) source

Set the vertices of this mesh geometry

Params:

NameTypeAttributeDescription
verticesObject

public setVisible(value: Boolean) source

Set the visibility of this mesh

Params:

NameTypeAttributeDescription
valueBoolean

visible or not

public updateMesh() source

updateMesh

public updateStroke(inflateValue: Number) source

Utils to regenerate the stroke Mesh when already existing

Params:

NameTypeAttributeDescription
inflateValueNumber

stroke width

Private Methods

private getUVFromIntersectionPoint(point: Vector3, p1: Vector3, p2: Vector3, p3: Vector3, uv1: Vector2, uv2: Vector2, uv3: Vector2): Vector2 source

getUVFromIntersectionPoint

Params:

NameTypeAttributeDescription
pointVector3

the intersection point as a Vector3

p1Vector3

vertices of face1

p2Vector3

vertices of face2

p3Vector3

vertices of face3

uv1Vector2

uvs of face1

uv2Vector2

uvs of face2

uv3Vector2

uvs of face3

Return:

Vector2

Uvs

private setPointOfIntersection(line: Object, plane: Object, intersectionPoint: Object): Object source

setPointOfIntersection

Params:

NameTypeAttributeDescription
lineObject

three.js line

planeObject

three.js plane

intersectionPointObject

object to be used to store the resulting Vector3

Return:

Object

description

private updateMaterial() source

Updates this mesh material