Represent a group of nodes within the scene that are associated with each other

Implements

  • IDisposable

Constructors

Accessors

  • get rootMesh(): Mesh
  • Asset container root mesh of this model. It's the ancestor of all meshes in this model, including bounding box meshes, shadow plane meshes, etc.

    Returns Mesh

  • get uniqueId(): string
  • The unique id of the model

    Returns string

Methods

  • Release all the resources held by Model

    Returns void

  • Get all child-meshes of the root mesh

    Parameters

    • Optionalpredicate: ((mesh: AbstractMesh) => boolean)

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored. By default, excludes bounding box meshes, shadow plane meshes, etc.

        • (mesh): boolean
        • Parameters

          • mesh: AbstractMesh

          Returns boolean

    Returns AbstractMesh[]

    an array of AbstractMesh that pass the test

  • Get a BABYLON object of the overall bounding box. If the model has already been removed from scene, it returns BoundingBox(Vector3.Zero(), Vector3.Zero()).

    Returns BoundingBox

    bounding box information in BoundingBox

  • Get overall bounding box's world's x, y, z dimensions. If the model has already been removed from scene, it returns Vector3.Zero().

    Returns Vector3

    x, y, z dimensions in Vector3

  • Check if this model contains the provided mesh

    Parameters

    • mesh: AbstractMesh

      the provided mesh

    Returns boolean

    true if this model contains the provided mesh, else false

  • Check if this model contains the provided node

    Parameters

    • node: Node

      the provided node

    Returns boolean

    true if this model contains the provided node, else false

  • Check whether the model is removed from the scene

    Returns boolean

    true if the model is removed from the scene, else false

  • Move entire scene element's root node from the overall bounding box center to a given coordinate in World space. Default is moving to World origin.

    Parameters

    • targetCoordinate: Vector3 = ...

      target coordinate. Default: Vector3.Zero()

    Returns void

  • Remove all the resources held by Model from the scene

    Returns void

  • Removes all elements associated with the shadow light-based ground contact shadow

    Returns void

  • Removes all elements associated with the depth map-based ground contact shadow

    Returns void

  • Add soft shadow on ground using shadow light from top down.

    Parameters

    • shadowValue: number = 0.3

      Range from 0 to 1. The value will be applied to shadow color's R, G, B.

    • blurKernel: number = 128

      Kernel size of the blur pass.

    • shadowLightAtBoundingBoxTop: boolean = true

      Set up the init position of shadow light. True: place shadow light at the max Y of the overall bounding box. False: place shadow light at the min Y of the overall bounding box.

    • shadowLightHeightOffset: number = 0.0

      Additional Y direction offset for shadow light from the init position.

    • depthScale: number = 50

      The depth scale factor used to improve the shadow quality by adjusting depth precision.

    • bias: number = 0.0005

      A small bias value applied to the shadow map to reduce shadow acne (unwanted shadow artifacts).

    • normalBias: number = 0.0

      A bias value applied in the direction of the geometry's normals to further reduce self-shadowing artifacts.

    Returns void

    // Example usage
    model.showShadowOnGround(0.3, 120, true, 0.15, 1);
  • Creates and displays a contact shadow on the ground using a depth map from bottom up The shadow can be blurred to create a softer effect.

    Parameters

    • options: {
          blurriness?: number;
          bottomUpCalculationRatio?: number;
          darkness?: number;
          gamma?: number;
          shadowMapResolution?: number;
      } = {}

      Optional parameters to configure the shadow rendering.

      • Optionalblurriness?: number

        The amount of blurriness applied to the shadow. Higher values create a softer shadow. Defaults to 110.

      • OptionalbottomUpCalculationRatio?: number

        The ratio used to calculate the camera's maxZ for the depth map rendering. Defaults to 1.0.

      • Optionaldarkness?: number

        The darkness of the shadow, with 1.0 being fully dark and 0.0 being fully transparent. Defaults to 1.15.

      • Optionalgamma?: number

        The gamma correction applied to the depth map for the shadow. Defaults to 0.4.

      • OptionalshadowMapResolution?: number

        The resolution of shadow texture map on ground. If the shadow map resolution is changed, the blurriness value will need to be adjusted proportionally. Defaults to 1024.

    Returns void

    // Example usage
    model.showShadowOnGroundDepthMap({
    bottomUpCalculationRatio: 1.0,
    darkness: 1.15,
    gamma: 0.4,
    blurriness: 110,
    shadowMapResolution: 1024,
    });
  • Toggle the visibility of the bounding box mesh

    Parameters

    • Optionalvisible: boolean

      force the bounding box mesh to be visible or invisible

    Returns void

  • Turn on/off matcap mode

    Parameters

    • matcapTextureUrl: string

      url of matcap texture to be used

    • OptionalforceEnabled: boolean

      force the matcap mode to be enabled or disabled

    Returns void

  • Toggle the visibility of the model

    Parameters

    • Optionalvisible: boolean

      force the model to be visible or invisible

    Returns void

  • Turn on/off wireframe mode

    Parameters

    • OptionalforceEnabled: boolean

      force the wireframe mode to be enabled or disabled

    Returns void