@kognifai/cogsengine
    Preparing search index...

    Class Mesh

    Meshes contain streams of vertex data in addition to index data and options defining geometry used for rendering and picking.

    Created by: Cogs.Resources.createMesh() Release using: Mesh.release()

    Hierarchy (View Summary)

    Index

    Accessors

    • get boundingBox(): BoundingBox

      Gets bounding box set using set boundingBox. Note! may be different from Cogs boundingbox if attaching to exising mesh.

      Returns BoundingBox

    • set boundingBox(value: BoundingBox): void

      Sets the bounding box for the Mesh. Override auto-calc. Highly recommended for performance.

      Parameters

      • value: BoundingBox

        Extents of the mesh positions in Local Coordinates.

      Returns void

    • get bridge(): Bridge

      Internal bridge access

      Returns Bridge

    • get colors(): Float32Array

      Gets RGBA colors.

      Returns Float32Array

      colors. Array length is 4*N.

    • set colors(values: Float32Array): void

      Sets RGBA color values.

      Parameters

      • values: Float32Array

        color data. Array length must be 4*N.

      Returns void

    • get id(): number

      Gets the COGS resource ID of the Resource

      Returns number

      resource ID

    • get indexes(): Uint32Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike>

      Get mesh indices.

      Returns Uint32Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike>

      indices. Returns type of index data set 32 or 16 bit.

    • set indexes(
          values: Uint32Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike>,
      ): void

      Set mesh indices.

      Parameters

      • values: Uint32Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike>

        32 or 16 bit indices.

      Returns void

    • get instanceColors(): Float32Array

      Gets Mesh instancing RGBA colors.

      Returns Float32Array

      colors. Array length is 4*N.

    • set instanceColors(values: Float32Array): void

      Sets Mesh instancing RGBA color values.

      Parameters

      • values: Float32Array

        color data. Array length must be 4*N.

      Returns void

    • get instancePositions(): Float32Array

      Gets Mesh instancing position data.

      Returns Float32Array

      Positions. Length is 3*N.

    • set instancePositions(values: Float32Array): void

      Sets Mesh instancing position data.

      Parameters

      • values: Float32Array

        Positions. Length must be N*3.

      Returns void

    • get isReleased(): boolean

      Returns flag marking if resource is released

      Returns boolean

    • get name(): string

      Gets the optional name

      Returns string

      name of the resource

    • get normals(): Float32Array

      Gets normals data.

      Returns Float32Array

      Normals. Array length is 3*N.

    • set normals(values: Float32Array): void

      Sets normal data.

      Parameters

      • values: Float32Array

        Normals. Array length must be N*3.

      Returns void

    • get positions(): Float32Array

      Gets position data.

      Returns Float32Array

      Positions. Length is 3*N.

    • set positions(values: Float32Array): void

      Sets position data.

      Parameters

      • values: Float32Array

        Positions. Length must be N*3.

      Returns void

    • get primitiveType(): PrimitiveType

      Gets the primitive type used to interpret the vertex data. Note: If attached to existing mesh, primitive type is not read from the mesh.

      Returns PrimitiveType

      Selected primitive type.

    • set primitiveType(value: PrimitiveType): void

      Sets the primitive type used to interpret the vertex data.

      Parameters

      Returns void

    • get runtime(): Runtime

      Internal runtime access

      Returns Runtime

    • get tangents(): Float32Array

      Gets tangent data.

      Returns Float32Array

      tangents. Array length is 3*N.

    • set tangents(values: Float32Array): void

      Sets tangent data.

      Parameters

      • values: Float32Array

        Tangents. Array length must be N*3.

      Returns void

    • get texCoords(): Float32Array

      Gets texture coordinates.

      Returns Float32Array

      Texture Coordinates. Array length is 2*N.

    • set texCoords(values: Float32Array): void

      Sets texture coordinates.

      Parameters

      • values: Float32Array

        Texture Coordinates. Array length must be N*2.

      Returns void

    Methods

    • Compare two Cogs Resource types for equality.

      Parameters

      • other: Mesh

        Other resource.

      Returns boolean

      True if same Resource class type & ID and belongs to same Cogs instance.

    • Compare two Cogs Resource types for equality.

      Parameters

      Returns boolean

      True if same Resource class type & ID and belongs to same Cogs instance.

    • Log error message

      Parameters

      • message: string

      Returns void

    • Release to free resources after use. Also release local handle after creating resource and passing to Cogs.

      Returns void

      const model = runtime.ModelEntity.create("Model");
      const modelResource: runtime.resources.loadModel(modelPath);
      model.modelComponent.model = modelResource;
      modelResource.release(); // ModelComponent now sole owner

      internalRelease for actual release.

    • Take resource ownership. release() will release the resource. Can be used to release meshes loaded in scenes accessed through Mesh field getter.

      Returns void

    • Internal instance creator by runtime.resources.createMesh()

      Parameters

      • runtime: Runtime
      • Optionalname: string

      Returns Mesh

    • Create a Mesh from existing resource Called from field getter for Mesh

      Parameters

      Returns Mesh