@kognifai/cogsengine
    Preparing search index...

    Class MaterialInstance

    Resource wrapper for Cogs Material Instance. New resource is created using resources.loadMaterialInstance(..) Release using: MaterialInstance.release()

    Material instances represent a specialized Material combined with state for all its buffers and properties. All material instances created from the same material share the effect resource and properties of the material. Only the values contained in the buffers and properties may differ between MaterialInstances created from the same Material.

    Hierarchy (View Summary)

    Index

    Accessors

    • get bridge(): Bridge

      Internal bridge access

      Returns Bridge

    • get id(): number

      Gets the COGS resource ID of the Resource

      Returns number

      resource ID

    • 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 runtime(): Runtime

      Internal runtime access

      Returns Runtime

    Methods

    • Compare two Cogs Resource types for equality.

      Parameters

      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.

    • Select MaterialInstance permutation

      Parameters

      • value: string

        permutation name

      Returns void

    • Set property for Material instance

      Parameters

      • key: string

        Property key to set

      • value: MatInstDataTypes

        Property value. Numbers are interpreted as float. Note that vec3 etc can be used, but vec3.fromValues required. number[] array not allowed.

      Returns void

    • Set a texture property

      Parameters

      Returns void

    • Set addressing mode for a texture property

      Parameters

      • key: string

        Name of texture property

      • mode: AddressMode

        Texture address mode

      Returns void

    • Parameters

      Returns void

    • Select Material Instance variant.

      Parameters

      • key: string

        Name of variant

      • value: string | number | boolean

        Variant value. Value passed to Cogs is always string.

      Returns void

    • Internal: Create a MaterialInstance from existing resource Called from field getter for MaterialInstance

      Parameters

      Returns MaterialInstance