Helper class to set up a basic 3D demo with a Scene, Data, Viewer, WebGLRenderer, and View.

See @xeokit/sdk/demo for usage.

Constructors

Properties

data: Data

The Data created by the DemoHelper. Holds all data models.

maxViews: number

The maximum number of views to create.

modelsDir: string = "../../models"

Base directory for loading models, relative to the HTML page.

renderer: WebGLRenderer

The WebGLRenderer created by the DemoHelper.

scene: Scene

The Scene created by the DemoHelper. Holds all 3D objects.

stats: {
    aabb: number[];
    data: DataModelStats;
    elapsedTime: number;
    endTime: number;
    memory: MemoryUsage;
    renderer: RenderStats;
    scene: SceneModelStats;
    startTime: number;
}

Statistics about the demo, available after calling finished().

viewer: Viewer

The Viewer created by the DemoHelper.

views: {
    [viewId: string]: {
        cameraFlight: CameraFlightAnimation;
        view: View;
        viewController: ViewController;
    };
}

Tracks created Views by their IDs, along with their associated CameraFlightAnimation and ViewController.

Accessors

Methods

  • Creates a new View in the Viewer.

    When viewParams.elementId and viewParams.htmlElement are omitted, this method auto-creates a canvas element, passes it to viewer.createView, and lays it out snugly with other auto-created canvases inside the window.

    Auto-created canvases are given z-index: 100000.

    The first View created becomes the DemoHelper's primary view, and gets a CameraFlightAnimation and ViewController.

    Parameters

    • viewParams: ViewParams = {}

      Parameters for the View.

    Returns View

    The created View.

  • Loads a model into the Scene and/or Data layers using a format-specific loader.

    This method:

    • Resolves or creates SceneModel and DataModel instances when not provided
    • Fetches model data from params.src or a default path derived from modelId
    • Selects the appropriate loader based on params.format
    • Delegates parsing and population to the corresponding loader implementation

    Supported formats:

    Default source resolution: If params.src is not provided, the source path is inferred as: ../../models/{modelId}/{format}/model.{ext}

    Model creation behavior:

    • If sceneModel is not provided, a new one is created via this.scene.createModel()
    • If dataModel is not provided, a new one is created via this.data.createModel()
    • Created model IDs are derived from modelId when available

    Parameters

    • params: {
          dataModel?: DataModel;
          format: string;
          modelId?: string;
          sceneModel?: SceneModel;
          src?: string;
      }

      Configuration for loading the model

      • OptionaldataModel?: DataModel

        Optional existing DataModel to populate

      • format: string

        Model format determining which loader to use

      • OptionalmodelId?: string

        Optional identifier used for default paths and generated model IDs

      • OptionalsceneModel?: SceneModel

        Optional existing SceneModel to populate

      • Optionalsrc?: string

        Optional explicit source URL/path for the model file

    • options: any

      Loader-specific options passed through to the underlying loader

    Returns Promise<SDKResult<any>>

    A promise resolving to an SDKResult containing the loader result

    Error

    • If model creation fails
    • If the format is unsupported
    • If fetching or parsing the model data fails