Abstract class used to provide common properties and functions for creating and managing the viewer

Hierarchy (view full)

Implements

  • IDisposable

Constructors

  • Instantiate a new AbstractScene

    Parameters

    • canvas: Nullable<HTMLCanvasElement>

      defines the canvas to use for rendering. If NullEngine is used, set the canvas as null.

    • presetConfig: Config

      pre-defined configuration

    • configOverride: Config = {}

      used to override parameters in pre-defined configuration

    Returns AbstractScene

Properties

_canvas: Nullable<HTMLCanvasElement>
_engine: Engine
_filesInput: Nullable<FilesInput>
_initialConfig: Config
_modelLoader: ModelLoader
_observableManager: ObservableManager
_sceneManager: SceneManager

Accessors

  • get canvas(): Nullable<HTMLCanvasElement>
  • Define the canvas to use for rendering

    Returns Nullable<HTMLCanvasElement>

  • get engine(): Engine
  • The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio

    Returns Engine

  • get filesInput(): Nullable<FilesInput>
  • Class used to help managing file picking and drag-n-drop

    Returns Nullable<FilesInput>

Methods

  • Create the engine. Returns a promise in case async calls are needed.

    Returns Promise<Engine>

    a promise of Babylon Engine

  • Registers gltfLoaderExtensions which are enabled in the extensionConfig

    Returns void

  • Gets a camera using its name

    Parameters

    • cameraName: string

      defines the camera's name

    Returns Nullable<Camera>

    the camera or null if none found.

  • Asynchronously prepare Babylon engine and scene manager

    Returns Promise<void>

  • Asynchronously import a glTF or glb file into the scene. Either a URL path to the file must be provided, or the base64 based string of a glb file (starts with 'data:').

    Parameters

    • url: string

      URL path to the glTF or glb file, or base64 based string (starts with 'data:')

    • OptionaldisableAnimation: boolean

      whether disable animation of the loaded model (default: false)

    • OptionalmodelName: string

      the name of model

    • Optionaloptions: LoadGltfOptions

      optional config

    Returns Promise<Model>

    A promise of Model

    Error if no glTF content or url provided

  • Import a glTF or glb model from files into the scene.

    Notes: The loaded model can be found: 1) in AbstractScene.sceneManager.models map 2) by adding an observer to AbstractScene.observableManager.onModelLoadedObservable

    Parameters

    • files: File[]

      A list of files, which can be a GLB file or a GLTF file along with multiple texture files and bin files

    Returns void

  • Register a new action to be preformed after a gltf/glb scene file has been loaded

    Parameters

    • action: ((scene: Scene) => void)

      a function which takes a scene as input and preforms some process after it has been loaded then returns void

        • (scene): void
        • Parameters

          • scene: Scene

          Returns void

    Returns void

  • Capture a screenshot of the current rendering

    Parameters

    • size: number | IScreenshotSize

      This parameter can be set to a single number or to an object with the following (optional) properties: precision, width, height. If a single number is passed, it will be used for both width and height. If an object is passed, the screenshot size will be derived from the parameters. The precision property is a multiplier allowing rendering at a higher or lower resolution

    • usingRenderTarget: boolean = false

      whether to use CreateScreenshotUsingRenderTarget function. Default: false

    Returns Promise<string>

    base64 encoded string

  • Turn on/off debug layer

    Parameters

    • OptionalforceHide: boolean

      if it's set to true, always hide the debug mode

    Returns void

  • Turn on/off a specific lighting rig

    Parameters

    • lightingName: string

      the name of lighting, i.e. the key in Config.lightingConfig

    • Optionalvisible: boolean

      force the lighting to be visible or invisible

    Returns void

  • Asynchronously update the scene's configuration, including camera, lights, environment, etc.

    Parameters

    • newConfig: Partial<Config>

      the delta that should be configured. This includes only the changes.

    Returns Promise<void>

  • Adjust camara zoom-in level on models. Only works for ArcRotateCamera with FramingBehavior enabled. FramingBehavior must be configured before loading models.

    Parameters

    • models: Model[]

      A list of models used to determine camera zoom-in level

    Returns void