omega-game-engine
    Preparing search index...

    Represents a procedurally generated sphere primitive with positions, normals, and UV coordinates. *

    Hierarchy (View Summary)

    Indexable

    • [key: string]: any
    Index

    Constructors

    • Creates a new instance of SpherePrimitive.

      • This constructor generates a sphere mesh by creating a grid of vertices using spherical coordinates.

      Parameters

      • Optionalradius: number = 1.0

        The radius of the sphere. *

      • Optionalslices: number = 32

        The number of vertical segments (longitude lines). *

      • Optionalstacks: number = 16

        The number of horizontal segments (latitude lines).

      Returns SpherePrimitive

    Properties

    _className: string
    _serializationIgnoreKeys: string[]
    _uuid: string
    bitangents?: vec3[]

    The array of bitangent vectors. *

    indices: number[]

    The array of vertex indices. *

    name: string = ''
    normals: vec3[]

    The array of vertex normals. *

    tangents?: vec3[]

    The array of tangent vectors. *

    uvs: vec2[]

    The array of texture coordinates. *

    vertices: vec3[]

    The array of vertex positions. *

    Accessors

    • get uuid(): string

      The unique identifier for the mesh data.

      Returns string

    Methods

    • Calculates smooth normals and generates indices for the mesh based on its vertices.

      • It computes face normals and then averages them for vertex normals to create a smooth appearance.
      • The calculated normals and indices are stored directly in this.normals and this.indices.

      Returns void

    • Calculates tangents and bitangents for the mesh and populates the instance's arrays.

      • This method should be called after the mesh's vertices, normals, UVs, and indices are set.

      Returns void

    • Inverts the direction of all normal vectors in the mesh.

      • This is useful for flipping faces or correcting normal orientations.

      Returns void

    • Calculates a bounding sphere for this mesh using its internal vertices. The sphere's center is the mesh's centroid.

      Parameters

      • vertices: vec3[]

      Returns null | BoundingSphere

      A BoundingSphere object, or null if the mesh has no vertices.

    • Creates a new MeshData instance.

      Parameters

      • Optionalvertices: vec3[]

        The array of vertex positions. *

      • Optionalnormals: vec3[] = []

        The array of vertex normals. *

      • Optionaluvs: vec2[] = []

        The array of texture coordinates. *

      • Optionalindices: number[] = []

        The array of vertex indices. *

      Returns MeshData

      • A new MeshData instance.