declare module "babylonjs-viewer/renderOnlyIndex" { import { RenderOnlyViewer } from "babylonjs-viewer/viewer/renderOnlyViewer"; import "babylonjs-loaders/glTF/2.0"; import "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent"; import "babylonjs/Debug/debugLayer"; import "babylonjs/Meshes/Builders/planeBuilder"; import "babylonjs/Meshes/Builders/boxBuilder"; import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader"; import "babylonjs/Materials/Textures/Loaders/envTextureLoader"; import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader"; import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent"; export { RenderOnlyViewer }; } declare module "babylonjs-viewer/interfaces" { export enum CameraBehavior { AUTOROTATION = 0, BOUNCING = 1, FRAMING = 2 } } declare module "babylonjs-viewer/initializer" { /** * Will attach an init function the DOMContentLoaded event. * The init function will be removed automatically after the event was triggered. */ export function initListeners(): void; /** * Select all HTML tags on the page that match the selector and initialize a viewer * * @param selector the selector to initialize the viewer on (default is 'babylon') */ export function InitTags(selector?: string): void; } declare module "babylonjs-viewer/index" { import { mapperManager } from "babylonjs-viewer/configuration/mappers"; import { viewerGlobals } from "babylonjs-viewer/configuration/globals"; import { viewerManager } from "babylonjs-viewer/viewer/viewerManager"; import { DefaultViewer } from "babylonjs-viewer/viewer/defaultViewer"; import { AbstractViewer } from "babylonjs-viewer/viewer/viewer"; import { telemetryManager } from "babylonjs-viewer/managers/telemetryManager"; import { ModelLoader } from "babylonjs-viewer/loader/modelLoader"; import { ViewerModel, ModelState } from "babylonjs-viewer/model/viewerModel"; import { AnimationPlayMode, AnimationState } from "babylonjs-viewer/model/modelAnimation"; import { ILoaderPlugin } from "babylonjs-viewer/loader/plugins/loaderPlugin"; import { AbstractViewerNavbarButton } from "babylonjs-viewer/templating/viewerTemplatePlugin"; import { registerCustomOptimizer } from "babylonjs-viewer/optimizer/custom/index"; /** * BabylonJS Viewer * * An HTML-Based viewer for 3D models, based on BabylonJS and its extensions. */ import * as BABYLON from "babylonjs/index"; import "babylonjs-loaders/index"; import { InitTags } from "babylonjs-viewer/initializer"; const disableInit: boolean; /** * Dispose all viewers currently registered */ function disposeAll(): void; const Version: string; export { BABYLON, Version, InitTags, DefaultViewer, AbstractViewer, viewerGlobals, telemetryManager, disableInit, viewerManager, mapperManager, disposeAll, ModelLoader, ViewerModel, AnimationPlayMode, AnimationState, ModelState, ILoaderPlugin, AbstractViewerNavbarButton, registerCustomOptimizer, }; export { GLTF2 } from "babylonjs-loaders/glTF/index"; export * from "babylonjs-viewer/configuration/index"; } declare module "babylonjs-viewer/viewer/viewerWithTemplate" { import { AbstractViewer } from "babylonjs-viewer/viewer/viewer"; import { ConfigurationLoader } from "babylonjs-viewer/configuration/loader"; /** * The AbstractViewer is the center of Babylon's viewer. * It is the basic implementation of the default viewer and is responsible of loading and showing the model and the templates */ export abstract class AbstractViewerWithTemplate extends AbstractViewer { protected getConfigurationLoader(): ConfigurationLoader; } } declare module "babylonjs-viewer/viewer/viewerManager" { import { Observable } from "babylonjs/Misc/observable"; import { AbstractViewer } from "babylonjs-viewer/viewer/viewer"; /** * The viewer manager is the container for all viewers currently registered on this page. * It is possible to have more than one viewer on a single page. */ export class ViewerManager { private _viewers; /** * A callback that will be triggered when a new viewer was added */ onViewerAdded: (viewer: AbstractViewer) => void; /** * Will notify when a new viewer was added */ onViewerAddedObservable: Observable; /** * Will notify when a viewer was removed (disposed) */ onViewerRemovedObservable: Observable; constructor(); /** * Adding a new viewer to the viewer manager and start tracking it. * @param viewer the viewer to add */ addViewer(viewer: AbstractViewer): void; /** * remove a viewer from the viewer manager * @param viewer the viewer to remove */ removeViewer(viewer: AbstractViewer): void; /** * Get a viewer by its baseId (if the container element has an ID, it is the this is. if not, a random id was assigned) * @param id the id of the HTMl element (or the viewer's, if none provided) * @returns the viewer associated with the given id (if found) */ getViewerById(id: string): AbstractViewer; /** * Get a viewer using a container element * @param element the HTML element to search viewers associated with * @returns the viewer associated with the given element (if found) */ getViewerByHTMLElement(element: HTMLElement): AbstractViewer | null; /** * Get a promise that will fulfill when this viewer was initialized. * Since viewer initialization and template injection is asynchronous, using the promise will guaranty that * you will get the viewer after everything was already configured. * @param id the viewer id to find * @returns a promise that will resolve to the viewer */ getViewerPromiseById(id: string): Promise; private _onViewerAdded; /** * dispose the manager and all of its associated viewers */ dispose(): void; } export const viewerManager: ViewerManager; } declare module "babylonjs-viewer/viewer/viewer" { import { Engine } from "babylonjs/Engines/engine"; import { ISceneLoaderPlugin, ISceneLoaderPluginAsync, ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader"; import { Observable } from "babylonjs/Misc/observable"; import { Scene } from "babylonjs/scene"; import { ConfigurationContainer } from "babylonjs-viewer/configuration/configurationContainer"; import { RenderOnlyConfigurationLoader } from "babylonjs-viewer/configuration/renderOnlyLoader"; import { ModelLoader } from "babylonjs-viewer/loader/modelLoader"; import { ObservablesManager } from "babylonjs-viewer/managers/observablesManager"; import { SceneManager } from "babylonjs-viewer/managers/sceneManager"; import { ViewerModel } from "babylonjs-viewer/model/viewerModel"; import { ViewerConfiguration } from "babylonjs-viewer/configuration/configuration"; import { IObserversConfiguration } from "babylonjs-viewer/configuration/interfaces/observersConfiguration"; import { IModelConfiguration } from "babylonjs-viewer/configuration/interfaces/modelConfiguration"; import "babylonjs/Misc/observable.extensions"; /** * The AbstractViewer is the center of Babylon's viewer. * It is the basic implementation of the default viewer and is responsible of loading and showing the model and the templates */ export abstract class AbstractViewer { containerElement: Element; /** * Babylon Engine corresponding with this viewer */ engine: Engine; /** * The ID of this viewer. it will be generated randomly or use the HTML Element's ID. */ readonly baseId: string; /** * The last loader used to load a model. * @deprecated */ lastUsedLoader: ISceneLoaderPlugin | ISceneLoaderPluginAsync; /** * The ModelLoader instance connected with this viewer. */ modelLoader: ModelLoader; /** * A flag that controls whether or not the render loop should be executed */ runRenderLoop: boolean; /** * The scene manager connected with this viewer instance */ sceneManager: SceneManager; /** * Will notify when the scene was initialized */ get onSceneInitObservable(): Observable; /** * will notify when the engine was initialized */ get onEngineInitObservable(): Observable; /** * Will notify when a new model was added to the scene. * Note that added does not necessarily mean loaded! */ get onModelAddedObservable(): Observable; /** * will notify after every model load */ get onModelLoadedObservable(): Observable; /** * will notify when any model notify of progress */ get onModelLoadProgressObservable(): Observable; /** * will notify when any model load failed. */ get onModelLoadErrorObservable(): Observable<{ message: string; exception: any; }>; /** * Will notify when a model was removed from the scene; */ get onModelRemovedObservable(): Observable; /** * will notify when a new loader was initialized. * Used mainly to know when a model starts loading. */ get onLoaderInitObservable(): Observable; /** * Observers registered here will be executed when the entire load process has finished. */ get onInitDoneObservable(): Observable; /** * Functions added to this observable will be executed on each frame rendered. */ get onFrameRenderedObservable(): Observable; /** * Observers registered here will be executed when VR more is entered. */ get onEnteringVRObservable(): Observable; /** * Observers registered here will be executed when VR mode is exited. */ get onExitingVRObservable(): Observable; observablesManager: ObservablesManager; /** * The canvas associated with this viewer */ protected _canvas: HTMLCanvasElement; /** * The (single) canvas of this viewer */ get canvas(): HTMLCanvasElement; /** * is this viewer disposed? */ protected _isDisposed: boolean; /** * registered onBeforeRender functions. * This functions are also registered at the native scene. The reference can be used to unregister them. */ protected _registeredOnBeforeRenderFunctions: Array<() => void>; /** * The configuration loader of this viewer */ protected _configurationLoader: RenderOnlyConfigurationLoader; /** * Is the viewer already initialized. for internal use. */ protected _isInit: boolean; protected _configurationContainer: ConfigurationContainer; get configurationContainer(): ConfigurationContainer; protected getConfigurationLoader(): RenderOnlyConfigurationLoader; constructor(containerElement: Element, initialConfiguration?: ViewerConfiguration); /** * get the baseId of this viewer * @returns the baseId of this viewer */ getBaseId(): string; /** * Do we have a canvas to render on, and is it a part of the scene * @returns true if the canvas is in the DOM */ isCanvasInDOM(): boolean; /** * Is the engine currently set to render even when the page is in background */ get renderInBackground(): boolean; /** * Set the viewer's background rendering flag. */ set renderInBackground(value: boolean); /** * Get the configuration object. This is a reference only. * The configuration can ONLY be updated using the updateConfiguration function. * changing this object will have no direct effect on the scene. */ get configuration(): ViewerConfiguration; /** * force resizing the engine. */ forceResize(): void; protected _hdToggled: boolean; toggleHD(): void; protected _vrToggled: boolean; private _vrModelRepositioning; protected _vrScale: number; protected _vrInit: boolean; toggleVR(): void; protected _initVR(): void; /** * The resize function that will be registered with the window object */ protected _resize: () => void; protected _onConfigurationLoaded(configuration: ViewerConfiguration): void; /** * Force a single render loop execution. */ forceRender(): void; /** * render loop that will be executed by the engine * @param force */ protected _render: (force?: boolean) => void; /** * Takes a screenshot of the scene and returns it as a base64 encoded png. * @param callback optional callback that will be triggered when screenshot is done. * @param width Optional screenshot width (default to 512). * @param height Optional screenshot height (default to 512). * @returns a promise with the screenshot data */ takeScreenshot(callback?: (data: string) => void, width?: number, height?: number): Promise; /** * Update the current viewer configuration with new values. * Only provided information will be updated, old configuration values will be kept. * If this.configuration was manually changed, you can trigger this function with no parameters, * and the entire configuration will be updated. * @param newConfiguration the partial configuration to update or a URL to a JSON holding the updated configuration * */ updateConfiguration(newConfiguration?: Partial | string): void; /** * this is used to register native functions using the configuration object. * This will configure the observers. * @param observersConfiguration observers configuration */ protected _configureObservers(observersConfiguration: IObserversConfiguration): void; /** * Dispose the entire viewer including the scene and the engine */ dispose(): void; /** * This will prepare the container element for the viewer */ protected abstract _prepareContainerElement(): void; /** * This function will execute when the HTML templates finished initializing. * It should initialize the engine and continue execution. * * @returns The viewer object will be returned after the object was loaded. */ protected _onTemplatesLoaded(): Promise; /** * This will force the creation of an engine and a scene. * It will also load a model if preconfigured. * But first - it will load the extendible onTemplateLoaded()! * @returns A promise that will resolve when the template was loaded */ protected _onTemplateLoaded(): Promise; /** * Initialize the engine. Returns a promise in case async calls are needed. * * @protected * @returns {Promise} * @memberof Viewer */ protected _initEngine(): Promise; private _isLoading; /** * Initialize a model loading. The returned object (a ViewerModel object) will be loaded in the background. * The difference between this and loadModel is that loadModel will fulfill the promise when the model finished loading. * * @param modelConfig model configuration to use when loading the model. * @param clearScene should the scene be cleared before loading this model * @returns a ViewerModel object that is not yet fully loaded. */ initModel(modelConfig: string | File | IModelConfiguration, clearScene?: boolean): ViewerModel; /** * load a model using the provided configuration. * This function, as opposed to initModel, will return a promise that resolves when the model is loaded, and rejects with error. * If you want to attach to the observables of the model, use initModel instead. * * @param modelConfig the model configuration or URL to load. * @param clearScene Should the scene be cleared before loading the model * @returns a Promise the fulfills when the model finished loading successfully. */ loadModel(modelConfig: string | File | IModelConfiguration, clearScene?: boolean): Promise; private _fpsTimeoutInterval; protected _initTelemetryEvents(): void; /** * Injects all the spectre shader in the babylon shader store */ protected _injectCustomShaders(): void; } } declare module "babylonjs-viewer/viewer/renderOnlyViewer" { import { ViewerConfiguration } from "babylonjs-viewer/configuration/configuration"; import { AbstractViewer } from "babylonjs-viewer/viewer/viewer"; import "babylonjs/Misc/observable.extensions"; export class RenderOnlyViewer extends AbstractViewer { containerElement: Element; constructor(containerElement: Element, initialConfiguration?: ViewerConfiguration); initialize(): Promise; protected _prepareContainerElement(): void; } } declare module "babylonjs-viewer/viewer/defaultViewer" { import { Template } from "babylonjs-viewer/templating/templateManager"; import { TemplateManager } from "babylonjs-viewer/templating/templateManager"; import { AbstractViewerWithTemplate } from "babylonjs-viewer/viewer/viewerWithTemplate"; import { ViewerModel } from "babylonjs-viewer/model/viewerModel"; import { IViewerTemplatePlugin } from "babylonjs-viewer/templating/viewerTemplatePlugin"; import { ViewerConfiguration } from "babylonjs-viewer/configuration/configuration"; import { IModelConfiguration } from "babylonjs-viewer/configuration/interfaces/modelConfiguration"; import "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent"; /** * The Default viewer is the default implementation of the AbstractViewer. * It uses the templating system to render a new canvas and controls. */ export class DefaultViewer extends AbstractViewerWithTemplate { containerElement: Element; /** * The corresponsing template manager of this viewer. */ templateManager: TemplateManager; fullscreenElement?: Element; /** * Create a new default viewer * @param containerElement the element in which the templates will be rendered * @param initialConfiguration the initial configuration. Defaults to extending the default configuration */ constructor(containerElement: Element, initialConfiguration?: ViewerConfiguration); private _registeredPlugins; registerTemplatePlugin(plugin: IViewerTemplatePlugin): void; /** * This will be executed when the templates initialize. * @returns a promise that will be resolved when the templates are loaded */ protected _onTemplatesLoaded(): Promise; private _initNavbar; private _animationList; private _currentAnimation; private _isAnimationPaused; private _resumePlay; private _handlePointerClick; /** * Plays or Pauses animation * @param noUiUpdate */ private _togglePlayPause; private _oldIdleRotationValue; /** * Control progress bar position based on animation current frame */ private _updateProgressBar; /** * Update Current Animation Speed * @param speed * @param paramsObject */ private _updateAnimationSpeed; /** * Update Current Animation Type * @param data * @param data.label * @param data.value * @param paramsObject */ private _updateAnimationType; protected _initVR(): void; /** * Toggle fullscreen of the entire viewer */ toggleFullscreen: () => void; /** * Preparing the container element to present the viewer */ protected _prepareContainerElement(): void; /** * This function will configure the templates and update them after a model was loaded * It is mainly responsible to changing the title and subtitle etc'. * @param model the model to be used to configure the templates by */ protected _configureTemplate(model?: ViewerModel): void; /** * This will load a new model to the default viewer * overriding the AbstractViewer's loadModel. * The scene will automatically be cleared of the old models, if exist. * @param model the configuration object (or URL) to load. * @returns a promise that will be resolved when the model is loaded */ loadModel(model?: string | File | IModelConfiguration): Promise; private _onModelLoaded; /** * Show the overlay and the defined sub-screen. * Mainly used for help and errors * @param subScreen the name of the subScreen. Those can be defined in the configuration object * @returns a promise that will be resolved when the overlay is shown */ showOverlayScreen(subScreen: string): Promise | Promise