ProtoTwin API
    Preparing search index...

    Class Materials

    Materials database.

    The materials database stores libraries of materials usable in the model.

    Index

    Properties

    The custom materials library.

    Contains materials created through through the inspector, through scripting or by importing assets.

    Accessors

    Methods

    • Creates a custom material and adds it to the custom material library.

      Parameters

      • name: string

        The unique name for the custom material.

      Returns null | CustomMaterial

      The created custom material, or null if the material name was not unique.

    • Adds a remote material library to the database.

      Parameters

      • path: string

        The path to the remote material library definition file.

      Returns null | RemoteMaterialLibrary

      The remote material library that was added, or null if the operation failed.

      This function will return null if the library has already been added or if the remote library could not be loaded from the specified path. The path specifies the location of a JSON file which contains the material definitions. See the standard library https://play.prototwin.com/assets/materials/library.json for an example library definition file.

    • Finds a material with the specified name.

      Parameters

      • name: string

        The material name.

      Returns null | Material

      The material, or null if not found.

      This function will first check the custom material library for a custom material with the specified name. If no custom material was found then it checks each remote library in the order in which the remote libraries were added.

    • Retrieves the remote material library with the specified path.

      Parameters

      • path: string

        The path to the remote material library definition file.

      Returns null | MaterialLibrary

      The corresponding remote material library, or null if not previously added.

    • Retrieves the remote material library with the specified path and adds it to the database if it hasn't already been added.

      Parameters

      • path: string

        The path to the remote material library definition file.

      Returns null | MaterialLibrary

      The corresponding remote material library, or null if the operation failed.

    • Removes the custom material with the specified name.

      Parameters

      • name: string

        The custom material name.

      Returns boolean

      True if the custom material was removed, false otherwise.

    • Removes the remote material library with the specified path from the database.

      Parameters

      • path: string

        The path to the remote material library definition file.

      Returns boolean

      True if the remote material library was removed, false otherwise.