The Mesh class. This mesh object has primitives (geometries) or a reference of 'original mesh'. If the latter, this mesh object is an 'instanced mesh', which has no primitives. Instanced meshes refer original mesh's primitives when drawing.

Implements

Constructors

Properties

tangentCalculationMode: number = 1

Specification of when calculate the tangent of a vertex to apply Normal texture (for pbr/MToon shader) 0: Not calculate tangent (not apply normal texture) 1: (default) Use original tangent in a vertex, if a vertex has tangent attribute. If a vertex does not have it, calculate a tangent in a shader. 2: Use original tangent in a vertex, if a vertex has tangent attribute. If a vertex does not have it, precalculate a tangent in the javascript. 3: Calculate all tangent in a shader. 4: Precalculate all tangent in the javascript

__mesh_uid_count: number = Mesh.invalidateMeshUID
invalidateMeshUID: -1 = -1

Accessors

  • get _variationVBOUid(): number
  • Internal

    Gets the variation VBO UID for internal use.

    Returns number

    The variation VBO resource handle

  • get primitivePositionUpdateCount(): number
  • Gets the primitive position update count.

    Returns number

    The number of times primitive positions have been updated

Methods

  • Internal

    Registers this mesh as belonging to a mesh component.

    Parameters

    • meshComponent: MeshComponent

      The mesh component that owns this mesh

    Returns void

  • Internal

    Calculates barycentric coordinates for all primitives in this mesh.

    Returns void

  • Internal

    Calculates face normals for primitives that don't have normal attributes.

    Returns void

  • Internal

    Called when primitive position data is updated. Updates the position update counter and moves related entities to Load stage.

    Returns void

  • Internal

    Updates VBO (Vertex Buffer Object) and VAO (Vertex Array Object) for all primitives.

    Returns void

  • Apply a material variant to the mesh

    Parameters

    • variantName: string

      a variant name

    Returns void

  • Performs ray casting against this mesh to find intersection points.

    Parameters

    • srcPointInLocal: IVector3

      The ray origin point in local space

    • directionInLocal: IVector3

      The ray direction in local space

    • dotThreshold: number = 0

      The dot product threshold for back-face culling (default: 0)

    Returns RaycastResultEx1

    Ray casting result with intersection information

  • Internal

    Deletes the variation VBO (Vertex Buffer Object).

    Returns boolean

    True if updated, false if not changed (not dirty)

  • Gets the current material variant name applied to this mesh. Returns empty string if no variant is applied or if primitives have different variants.

    Returns string

    The current variant name or empty string

  • Gets the index of a primitive within this mesh.

    Parameters

    • primitive: Primitive

      The primitive to find the index of

    Returns number

    The index of the primitive in the mesh

  • Gets the total number of primitives in this mesh.

    Returns number

    The number of primitives

  • Gets the VAO (Vertex Array Object) UID for the specified index.

    Parameters

    • index: number

      The index of the primitive

    Returns number

    The VAO resource handle

  • Gets the VAO (Vertex Array Object) UID for the specified primitive UID.

    Parameters

    • primitiveUid: number

      The UID of the primitive

    Returns number

    The VAO resource handle

  • Gets all available material variant names for this mesh.

    Returns string[]

    Array of variant names from all primitives

  • Checks if this mesh has blend-with-z-write primitives.

    Returns boolean

    True if blend-with-z-write primitives exist, false otherwise

  • Checks if this mesh has blend-without-z-write primitives.

    Returns boolean

    True if blend-without-z-write primitives exist, false otherwise

  • Checks if this mesh has opaque primitives.

    Returns boolean

    True if opaque primitives exist, false otherwise

  • Checks if this mesh has translucent primitives.

    Returns boolean

    True if translucent primitives exist, false otherwise

  • Checks if this mesh setup is completed and ready for rendering.

    Returns boolean

    True if setup is done, false otherwise

  • Internal

    Updates the variation VBO (Vertex Buffer Object) for instancing.

    Returns boolean

    True if updated, false if not changed (not dirty)