1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281 |
- /// <reference path="./babylon.d.ts"/>
- /// <reference path="./babylon.glTF2Interface.d.ts"/>
- /// <reference path="./babylonjs.loaders.d.ts"/>
- declare module "babylonjs-loaders"{ export=BABYLON;}
- // Generated by dts-bundle v0.7.3
- // Dependencies for this module:
- // ../../Tools/Gulp/babylonjs
- // ../../Tools/Gulp/babylonjs-loaders
- declare module BabylonViewer {
-
-
-
-
-
-
-
-
-
-
- /**
- * BabylonJS Viewer
- *
- * An HTML-Based viewer for 3D models, based on BabylonJS and its extensions.
- */
-
-
-
-
- let disableInit: boolean;
- /**
- * Dispose all viewers currently registered
- */
- function disposeAll(): void;
- const Version: string;
-
- }
- declare module BabylonViewer {
-
- /**
- * This is the mapper's interface. Implement this function to create your own mapper and register it at the mapper manager
- */
- export interface IMapper {
- map(rawSource: any): ViewerConfiguration;
- }
- /**
- * The MapperManager manages the different implemented mappers.
- * It allows the user to register new mappers as well and use them to parse their own configuration data
- */
- export class MapperManager {
- /**
- * The default mapper is the JSON mapper.
- */
- static DefaultMapper: string;
- constructor();
- /**
- * Get a specific configuration mapper.
- *
- * @param type the name of the mapper to load
- */
- getMapper(type: string): IMapper;
- /**
- * Use this functio to register your own configuration mapper.
- * After a mapper is registered, it can be used to parse the specific type fo configuration to the standard ViewerConfiguration.
- * @param type the name of the mapper. This will be used to define the configuration type and/or to get the mapper
- * @param mapper The implemented mapper
- */
- registerMapper(type: string, mapper: IMapper): void;
- /**
- * Dispose the mapper manager and all of its mappers.
- */
- dispose(): void;
- }
- /**
- * mapperManager is a singleton of the type MapperManager.
- * The mapperManager can be disposed directly with calling mapperManager.dispose()
- * or indirectly with using BabylonViewer.disposeAll()
- */
- export let mapperManager: MapperManager;
- }
- declare module BabylonViewer {
- export class ViewerGlobals {
- disableInit: boolean;
- disableWebGL2Support: boolean;
- }
- export let viewerGlobals: ViewerGlobals;
- }
- declare module BabylonViewer {
-
-
- /**
- * 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 {
- /**
- * 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: BABYLON.Observable<AbstractViewer>;
- /**
- * Will notify when a viewer was removed (disposed)
- */
- onViewerRemovedObservable: BABYLON.Observable<string>;
- 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)
- */
- getViewerById(id: string): AbstractViewer;
- /**
- * Get a viewer using a container element
- * @param element the HTML element to search viewers associated with
- */
- getViewerByHTMLElement(element: HTMLElement): AbstractViewer | undefined;
- /**
- * Get a promise that will fullfil 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
- */
- getViewerPromiseById(id: string): Promise<AbstractViewer>;
- /**
- * dispose the manager and all of its associated viewers
- */
- dispose(): void;
- }
- export let viewerManager: ViewerManager;
- }
- declare module BabylonViewer {
-
-
-
-
- /**
- * 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 AbstractViewer {
- containerElement: HTMLElement;
- /**
- * 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: HTMLElement, initialConfiguration?: ViewerConfiguration);
- /**
- * This will be executed when the templates initialize.
- */
- protected _onTemplatesLoaded(): Promise<AbstractViewer>;
- /**
- * 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.
- */
- loadModel(model?: string | IModelConfiguration): Promise<ViewerModel>;
- /**
- * 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
- */
- showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
- /**
- * Hide the overlay screen.
- */
- hideOverlayScreen(): Promise<string> | Promise<Template>;
- /**
- * show the viewer (in case it was hidden)
- *
- * @param visibilityFunction an optional function to execute in order to show the container
- */
- show(visibilityFunction?: ((template: Template) => Promise<Template>)): Promise<Template>;
- /**
- * hide the viewer (in case it is visible)
- *
- * @param visibilityFunction an optional function to execute in order to hide the container
- */
- hide(visibilityFunction?: ((template: Template) => Promise<Template>)): Promise<Template>;
- /**
- * Show the loading screen.
- * The loading screen can be configured using the configuration object
- */
- showLoadingScreen(): Promise<string> | Promise<Template>;
- /**
- * Hide the loading screen
- */
- hideLoadingScreen(): Promise<string> | Promise<Template>;
- }
- }
- declare module BabylonViewer {
-
-
-
-
-
-
-
- /**
- * The AbstractViewr 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: HTMLElement;
- /**
- * The corresponsing template manager of this viewer.
- */
- templateManager: TemplateManager;
- /**
- * Babylon BABYLON.Engine corresponding with this viewer
- */
- engine: BABYLON.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: BABYLON.ISceneLoaderPlugin | BABYLON.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;
- /**
- * the viewer configuration object
- */
- protected _configuration: ViewerConfiguration;
- /**
- * Will notify when the scene was initialized
- */
- onSceneInitObservable: BABYLON.Observable<BABYLON.Scene>;
- /**
- * will notify when the engine was initialized
- */
- onEngineInitObservable: BABYLON.Observable<BABYLON.Engine>;
- /**
- * Will notify when a new model was added to the scene.
- * Note that added does not neccessarily mean loaded!
- */
- onModelAddedObservable: BABYLON.Observable<ViewerModel>;
- /**
- * will notify after every model load
- */
- onModelLoadedObservable: BABYLON.Observable<ViewerModel>;
- /**
- * will notify when any model notify of progress
- */
- onModelLoadProgressObservable: BABYLON.Observable<BABYLON.SceneLoaderProgressEvent>;
- /**
- * will notify when any model load failed.
- */
- onModelLoadErrorObservable: BABYLON.Observable<{
- message: string;
- exception: any;
- }>;
- /**
- * Will notify when a model was removed from the scene;
- */
- onModelRemovedObservable: BABYLON.Observable<ViewerModel>;
- /**
- * will notify when a new loader was initialized.
- * Used mainly to know when a model starts loading.
- */
- onLoaderInitObservable: BABYLON.Observable<BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync>;
- /**
- * Observers registered here will be executed when the entire load process has finished.
- */
- onInitDoneObservable: BABYLON.Observable<AbstractViewer>;
- /**
- * Functions added to this observable will be executed on each frame rendered.
- */
- onFrameRenderedObservable: BABYLON.Observable<AbstractViewer>;
- /**
- * The canvas associated with this viewer
- */
- protected _canvas: HTMLCanvasElement;
- /**
- * The (single) canvas of this viewer
- */
- readonly 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: ConfigurationLoader;
- /**
- * Is the viewer already initialized. for internal use.
- */
- protected _isInit: boolean;
- constructor(containerElement: HTMLElement, initialConfiguration?: ViewerConfiguration);
- /**
- * get the baseId of this viewer
- */
- getBaseId(): string;
- /**
- * Do we have a canvas to render on, and is it a part of the scene
- */
- isCanvasInDOM(): boolean;
- /**
- * Set the viewer's background rendering flag.
- */
- renderInBackground: 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.
- */
- readonly configuration: ViewerConfiguration;
- /**
- * force resizing the engine.
- */
- forceResize(): void;
- /**
- * The resize function that will be registered with the window object
- */
- protected _resize: () => void;
- /**
- * Force a single render loop execution.
- */
- forceRender(): void;
- /**
- * render loop that will be executed by the engine
- */
- 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<string>;
- /**
- * 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
- *
- */
- updateConfiguration(newConfiguration?: Partial<ViewerConfiguration>): 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;
- /**
- * Dispoe the entire viewer including the scene and the engine
- */
- dispose(): void;
- /**
- * This will prepare the container element for the viewer
- */
- protected abstract _prepareContainerElement(): any;
- /**
- * This function will execute when the HTML templates finished initializing.
- * It should initialize the engine and continue execution.
- *
- * @returns {Promise<AbstractViewer>} The viewer object will be returned after the object was loaded.
- */
- protected _onTemplatesLoaded(): Promise<AbstractViewer>;
- /**
- * Initialize the engine. Retruns a promise in case async calls are needed.
- *
- * @protected
- * @returns {Promise<BABYLON.Engine>}
- * @memberof Viewer
- */
- protected _initEngine(): Promise<BABYLON.Engine>;
- /**
- * 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 | 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 initModle 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 | IModelConfiguration, clearScene?: boolean): Promise<ViewerModel>;
- protected _initTelemetryEvents(): void;
- /**
- * Injects all the spectre shader in the babylon shader store
- */
- protected _injectCustomShaders(): void;
- }
- }
- declare module BabylonViewer {
-
-
- /**
- * The data structure of a telemetry event.
- */
- export interface TelemetryData {
- event: string;
- session: string;
- date: Date;
- now: number;
- viewer?: AbstractViewer;
- detail: any;
- }
- /**
- * Receives Telemetry events and raises events to the API
- */
- export class TelemetryManager {
- onEventBroadcastedObservable: BABYLON.Observable<TelemetryData>;
- /**
- * Receives a telemetry event
- * @param event The name of the Telemetry event
- * @param details An additional value, or an object containing a list of property/value pairs
- */
- readonly broadcast: (event: string, viewer: AbstractViewer, details?: any) => void;
- /**
- * Log a Telemetry event for errors raised on the WebGL context.
- * @param engine The Babylon engine with the WebGL context.
- */
- flushWebGLErrors(viewer: AbstractViewer): void;
- /**
- * Enable or disable telemetry events
- * @param enabled Boolan, true if events are enabled
- */
- enable: boolean;
- /**
- * Returns the current session ID or creates one if it doesn't exixt
- * @return The current session ID
- */
- readonly session: string;
- /**
- * Disposes the telemetry manager
- */
- dispose(): void;
- }
- export const telemetryManager: TelemetryManager;
- }
- declare module BabylonViewer {
-
-
-
-
- /**
- * An instance of the class is in charge of loading the model correctly.
- * This class will continously be expended with tasks required from the specific loaders Babylon has.
- *
- * A Model loader is unique per (Abstract)Viewer. It is being generated by the viewer
- */
- export class ModelLoader {
- /**
- * Create a new Model loader
- * @param _viewer the viewer using this model loader
- */
- constructor(_viewer: AbstractViewer);
- /**
- * Adds a new plugin to the loader process.
- *
- * @param plugin the plugin name or the plugin itself
- */
- addPlugin(plugin: ILoaderPlugin | string): void;
- /**
- * Load a model using predefined configuration
- * @param modelConfiguration the modelConfiguration to use to load the model
- */
- load(modelConfiguration: IModelConfiguration): ViewerModel;
- cancelLoad(model: ViewerModel): void;
- /**
- * dispose the model loader.
- * If loaders are registered and are in the middle of loading, they will be disposed and the request(s) will be cancelled.
- */
- dispose(): void;
- }
- }
- declare module BabylonViewer {
-
-
-
-
-
- /**
- * The current state of the model
- */
- export enum ModelState {
- INIT = 0,
- LOADING = 1,
- LOADED = 2,
- ENTRY = 3,
- ENTRYDONE = 4,
- COMPLETE = 5,
- CANCELED = 6,
- ERROR = 7,
- }
- /**
- * The viewer model is a container for all assets representing a sngle loaded model.
- */
- export class ViewerModel implements BABYLON.IDisposable {
- protected _viewer: AbstractViewer;
- /**
- * The loader used to load this model.
- */
- loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync;
- /**
- * This model's root mesh (the parent of all other meshes).
- * This mesh does not(!) exist in the meshes array.
- */
- rootMesh: BABYLON.AbstractMesh;
- /**
- * ParticleSystems connected to this model
- */
- particleSystems: Array<BABYLON.ParticleSystem>;
- /**
- * Skeletons defined in this model
- */
- skeletons: Array<BABYLON.Skeleton>;
- /**
- * The current model animation.
- * On init, this will be undefined.
- */
- currentAnimation: IModelAnimation;
- /**
- * Observers registered here will be executed when the model is done loading
- */
- onLoadedObservable: BABYLON.Observable<ViewerModel>;
- /**
- * Observers registered here will be executed when the loader notified of a progress event
- */
- onLoadProgressObservable: BABYLON.Observable<BABYLON.SceneLoaderProgressEvent>;
- /**
- * Observers registered here will be executed when the loader notified of an error.
- */
- onLoadErrorObservable: BABYLON.Observable<{
- message: string;
- exception: any;
- }>;
- /**
- * Will be executed after the model finished loading and complete, including entry animation and lod
- */
- onCompleteObservable: BABYLON.Observable<ViewerModel>;
- /**
- * Observers registered here will be executed every time the model is being configured.
- * This can be used to extend the model's configuration without extending the class itself
- */
- onAfterConfigure: BABYLON.Observable<ViewerModel>;
- /**
- * The current model state (loaded, error, etc)
- */
- state: ModelState;
- /**
- * A loadID provided by the modelLoader, unique to ths (Abstract)Viewer instance.
- */
- loadId: number;
- loadInfo: BABYLON.GLTF2.IAsset;
- constructor(_viewer: AbstractViewer, modelConfiguration: IModelConfiguration);
- /**
- * Set whether this model is enabled or not.
- */
- enabled: boolean;
- loaderDone: boolean;
- /**
- * Get the viewer showing this model
- */
- getViewer(): AbstractViewer;
- /**
- * Add a mesh to this model.
- * Any mesh that has no parent will be provided with the root mesh as its new parent.
- *
- * @param mesh the new mesh to add
- * @param triggerLoaded should this mesh trigger the onLoaded observable. Used when adding meshes manually.
- */
- addMesh(mesh: BABYLON.AbstractMesh, triggerLoaded?: boolean): Promise<ViewerModel> | undefined;
- /**
- * get the list of meshes (excluding the root mesh)
- */
- readonly meshes: BABYLON.AbstractMesh[];
- /**
- * (Re-)set the model's entire configuration
- * @param newConfiguration the new configuration to replace the new one
- */
- configuration: IModelConfiguration;
- /**
- * Update the current configuration with new values.
- * Configuration will not be overwritten, but merged with the new configuration.
- * Priority is to the new configuration
- * @param newConfiguration the configuration to be merged into the current configuration;
- */
- updateConfiguration(newConfiguration: Partial<IModelConfiguration>): void;
- /**
- * Add a new animation group to this model.
- * @param animationGroup the new animation group to be added
- */
- addAnimationGroup(animationGroup: BABYLON.AnimationGroup): void;
- /**
- * Get the ModelAnimation array
- */
- getAnimations(): Array<IModelAnimation>;
- /**
- * Get the animations' names. Using the names you can play a specific animation.
- */
- getAnimationNames(): Array<string>;
- /**
- * Get an animation by the provided name. Used mainly when playing n animation.
- * @param name the name of the animation to find
- */
- protected _getAnimationByName(name: string): BABYLON.Nullable<IModelAnimation>;
- /**
- * Choose an initialized animation using its name and start playing it
- * @param name the name of the animation to play
- * @returns The model aniamtion to be played.
- */
- playAnimation(name: string): IModelAnimation;
- setCurrentAnimationByName(name: string): IModelAnimation;
- /**
- * Apply a material configuration to a material
- * @param material BABYLON.Material to apply configuration to
- */
- _applyModelMaterialConfiguration(material: BABYLON.Material): void;
- /**
- * Begin @animations with the specified @easingFunction
- * @param animations The BABYLON Animations to begin
- * @param duration of transition, in seconds
- * @param easingFunction An easing function to apply
- * @param easingMode A easing mode to apply to the easingFunction
- * @param onAnimationEnd Call back trigger at the end of the animation.
- */
- transitionTo(animations: BABYLON.Animation[], duration: number, easingFunction: any, easingMode: number | undefined, onAnimationEnd: () => void): void;
- /**
- * Stops and removes all animations that have been applied to the model
- */
- stopAllAnimations(): void;
- /**
- * Will remove this model from the viewer (but NOT dispose it).
- */
- remove(): void;
- /**
- * Dispose this model, including all of its associated assets.
- */
- dispose(): void;
- }
- }
- declare module BabylonViewer {
-
- /**
- * BABYLON.Animation play mode enum - is the animation looping or playing once
- */
- export const enum AnimationPlayMode {
- ONCE = 0,
- LOOP = 1,
- }
- /**
- * An enum representing the current state of an animation object
- */
- export const enum AnimationState {
- INIT = 0,
- PLAYING = 1,
- PAUSED = 2,
- STOPPED = 3,
- ENDED = 4,
- }
- /**
- * The different type of easing functions available
- */
- export const enum EasingFunction {
- Linear = 0,
- CircleEase = 1,
- BackEase = 2,
- BounceEase = 3,
- CubicEase = 4,
- ElasticEase = 5,
- ExponentialEase = 6,
- PowerEase = 7,
- QuadraticEase = 8,
- QuarticEase = 9,
- QuinticEase = 10,
- SineEase = 11,
- }
- /**
- * Defines a simple animation to be applied to a model (scale).
- */
- export interface ModelAnimationConfiguration {
- /**
- * Time of animation, in seconds
- */
- time: number;
- /**
- * Scale to apply
- */
- scaling?: BABYLON.Vector3;
- /**
- * Easing function to apply
- * See SPECTRE.EasingFunction
- */
- easingFunction?: number;
- /**
- * An Easing mode to apply to the easing function
- * See BABYLON.EasingFunction
- */
- easingMode?: number;
- }
- /**
- * This interface can be implemented to define new types of ModelAnimation objects.
- */
- export interface IModelAnimation {
- /**
- * Current animation state (playing, stopped etc')
- */
- readonly state: AnimationState;
- /**
- * the name of the animation
- */
- readonly name: string;
- /**
- * Get the max numbers of frame available in the animation group
- *
- * In correlation to an arry, this would be ".length"
- */
- readonly frames: number;
- /**
- * Get the current frame playing right now.
- * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
- *
- * In correlation to an array, this would be the current index
- */
- readonly currentFrame: number;
- /**
- * BABYLON.Animation's FPS value
- */
- readonly fps: number;
- /**
- * Get or set the animation's speed ration (Frame-to-fps)
- */
- speedRatio: number;
- /**
- * Gets or sets the aimation's play mode.
- */
- playMode: AnimationPlayMode;
- /**
- * Start the animation
- */
- start(): any;
- /**
- * Stop the animation.
- * This will fail silently if the animation group is already stopped.
- */
- stop(): any;
- /**
- * Pause the animation
- * This will fail silently if the animation is not currently playing
- */
- pause(): any;
- /**
- * Reset this animation
- */
- reset(): any;
- /**
- * Restart the animation
- */
- restart(): any;
- /**
- * Go to a specific
- * @param frameNumber the frame number to go to
- */
- goToFrame(frameNumber: number): any;
- /**
- * Dispose this animation
- */
- dispose(): any;
- }
- /**
- * The GroupModelAnimation is an implementation of the IModelAnimation interface using BABYLON's
- * native GroupAnimation class.
- */
- export class GroupModelAnimation implements IModelAnimation {
- /**
- * Create a new GroupModelAnimation object using an BABYLON.AnimationGroup object
- * @param _animationGroup The aniamtion group to base the class on
- */
- constructor(_animationGroup: BABYLON.AnimationGroup);
- /**
- * Get the animation's name
- */
- readonly name: string;
- /**
- * Get the current animation's state
- */
- readonly state: AnimationState;
- /**
- * Sets the speed ratio to use for all animations
- */
- speedRatio: number;
- /**
- * Get the max numbers of frame available in the animation group
- *
- * In correlation to an arry, this would be ".length"
- */
- readonly frames: number;
- /**
- * Get the current frame playing right now.
- * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
- *
- * In correlation to an array, this would be the current index
- */
- readonly currentFrame: number;
- /**
- * Get the FPS value of this animation
- */
- readonly fps: number;
- /**
- * Set the play mode.
- * If the animation is played, it will continue playing at least once more, depending on the new play mode set.
- * If the animation is not set, the will be initialized and will wait for the user to start playing it.
- */
- playMode: AnimationPlayMode;
- /**
- * Reset the animation group
- */
- reset(): void;
- /**
- * Restart the animation group
- */
- restart(): void;
- /**
- *
- * @param frameNumber Go to a specific frame in the animation
- */
- goToFrame(frameNumber: number): void;
- /**
- * Start playing the animation.
- */
- start(): void;
- /**
- * Pause the animation
- */
- pause(): void;
- /**
- * Stop the animation.
- * This will fail silently if the animation group is already stopped.
- */
- stop(): void;
- /**
- * Dispose this animation object.
- */
- dispose(): void;
- }
- }
- declare module BabylonViewer {
-
-
-
- /**
- * This interface defines the structure of a loader plugin.
- * Any of those functions will be called if (!) the loader supports those callbacks.
- * Any loader supports onInit, onLoaded, onError and onProgress.
- */
- export interface ILoaderPlugin {
- onInit?: (loader: BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync, model: ViewerModel) => void;
- onLoaded?: (model: ViewerModel) => void;
- onError?: (message: string, exception?: any) => void;
- onProgress?: (progressEvent: BABYLON.SceneLoaderProgressEvent) => void;
- onExtensionLoaded?: (extension: BABYLON.IGLTFLoaderExtension) => void;
- onParsed?: (parsedData: BABYLON.IGLTFLoaderData) => void;
- onMeshLoaded?: (mesh: BABYLON.AbstractMesh) => void;
- onTextureLoaded?: (texture: BABYLON.BaseTexture) => void;
- onMaterialLoaded?: (material: BABYLON.Material) => void;
- onComplete?: () => void;
- }
- }
- declare module BabylonViewer {
- /**
- * Will attach an init function the 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 BabylonViewer {
-
-
- export function getConfigurationKey(key: string, configObject: any): any;
- export interface ViewerConfiguration {
- version?: string;
- extends?: string;
- pageUrl?: string;
- configuration?: string | {
- url?: string;
- payload?: any;
- mapper?: string;
- };
- observers?: IObserversConfiguration;
- canvasElement?: string;
- model?: IModelConfiguration | string;
- scene?: ISceneConfiguration;
- optimizer?: ISceneOptimizerConfiguration | boolean;
- camera?: ICameraConfiguration;
- skybox?: boolean | ISkyboxConfiguration;
- ground?: boolean | IGroundConfiguration;
- lights?: {
- [name: string]: boolean | ILightConfiguration;
- };
- engine?: {
- renderInBackground?: boolean;
- antialiasing?: boolean;
- disableResize?: boolean;
- engineOptions?: BABYLON.EngineOptions;
- adaptiveQuality?: boolean;
- };
- templates?: {
- main: ITemplateConfiguration;
- [key: string]: ITemplateConfiguration;
- };
- customShaders?: {
- shaders?: {
- [key: string]: string;
- };
- includes?: {
- [key: string]: string;
- };
- };
- loaderPlugins?: {
- extendedMaterial?: boolean;
- msftLod?: boolean;
- telemetry?: boolean;
- minecraft?: boolean;
- [propName: string]: boolean | undefined;
- };
- lab?: {
- flashlight?: boolean | {
- exponent?: number;
- angle?: number;
- intensity?: number;
- diffuse?: {
- r: number;
- g: number;
- b: number;
- };
- specular?: {
- r: number;
- g: number;
- b: number;
- };
- };
- hideLoadingDelay?: number;
- assetsRootURL?: string;
- environmentMainColor?: {
- r: number;
- g: number;
- b: number;
- };
- environmentMap?: {
- /**
- * Environment map texture path in relative to the asset folder.
- */
- texture: string;
- /**
- * Default rotation to apply to the environment map.
- */
- rotationY: number;
- /**
- * Tint level of the main color on the environment map.
- */
- tintLevel: number;
- };
- defaultRenderingPipelines?: boolean | IDefaultRenderingPipelineConfiguration;
- };
- }
- /**
- * Defines an animation to be applied to a model (translation, scale or rotation).
- */
- export interface IModelAnimationConfiguration {
- /**
- * Time of animation, in seconds
- */
- time?: number;
- /**
- * Scale to apply
- */
- scaling?: {
- x: number;
- y: number;
- z: number;
- };
- /**
- * Easing function to apply
- * See SPECTRE.EasingFunction
- */
- easingFunction?: number;
- /**
- * An Easing mode to apply to the easing function
- * See BABYLON.EasingFunction
- */
- easingMode?: number;
- }
- export interface IDefaultRenderingPipelineConfiguration {
- sharpenEnabled?: boolean;
- bloomEnabled?: boolean;
- bloomThreshold?: number;
- depthOfFieldEnabled?: boolean;
- depthOfFieldBlurLevel?: BABYLON.DepthOfFieldEffectBlurLevel;
- fxaaEnabled?: boolean;
- imageProcessingEnabled?: boolean;
- defaultPipelineTextureType?: number;
- bloomScale?: number;
- chromaticAberrationEnabled?: boolean;
- grainEnabled?: boolean;
- bloomKernel?: number;
- hardwareScaleLevel?: number;
- bloomWeight?: number;
- bllomThreshold?: number;
- hdr?: boolean;
- samples?: number;
- }
- export interface IModelConfiguration {
- id?: string;
- url?: string;
- root?: string;
- file?: string;
- loader?: string;
- position?: {
- x: number;
- y: number;
- z: number;
- };
- rotation?: {
- x: number;
- y: number;
- z: number;
- w?: number;
- };
- scaling?: {
- x: number;
- y: number;
- z: number;
- };
- parentObjectIndex?: number;
- castShadow?: boolean;
- receiveShadows?: boolean;
- normalize?: boolean | {
- center?: boolean;
- unitSize?: boolean;
- parentIndex?: number;
- };
- title?: string;
- subtitle?: string;
- thumbnail?: string;
- animation?: {
- autoStart?: boolean | string;
- playOnce?: boolean;
- autoStartIndex?: number;
- };
- entryAnimation?: IModelAnimationConfiguration;
- exitAnimation?: IModelAnimationConfiguration;
- material?: {
- directEnabled?: boolean;
- directIntensity?: number;
- emissiveIntensity?: number;
- environmentIntensity?: number;
- [propName: string]: any;
- };
- /**
- * Rotation offset axis definition
- */
- rotationOffsetAxis?: {
- x: number;
- y: number;
- z: number;
- };
- /**
- * the offset angle
- */
- rotationOffsetAngle?: number;
- loaderConfiguration?: {
- maxLODsToLoad?: number;
- progressiveLoading?: boolean;
- };
- }
- export interface ISkyboxConfiguration {
- cubeTexture?: {
- noMipMap?: boolean;
- gammaSpace?: boolean;
- url?: string | Array<string>;
- };
- color?: {
- r: number;
- g: number;
- b: number;
- };
- pbr?: boolean;
- scale?: number;
- blur?: number;
- material?: {
- imageProcessingConfiguration?: IImageProcessingConfiguration;
- [propName: string]: any;
- };
- infiniteDistance?: boolean;
- }
- export interface IGroundConfiguration {
- size?: number;
- receiveShadows?: boolean;
- shadowLevel?: number;
- shadowOnly?: boolean;
- mirror?: boolean | {
- sizeRatio?: number;
- blurKernel?: number;
- amount?: number;
- fresnelWeight?: number;
- fallOffDistance?: number;
- textureType?: number;
- };
- texture?: string;
- color?: {
- r: number;
- g: number;
- b: number;
- };
- opacity?: number;
- material?: {
- [propName: string]: any;
- };
- }
- export interface ISceneConfiguration {
- debug?: boolean;
- clearColor?: {
- r: number;
- g: number;
- b: number;
- a: number;
- };
- mainColor?: {
- r: number;
- g: number;
- b: number;
- };
- imageProcessingConfiguration?: IImageProcessingConfiguration;
- environmentTexture?: string;
- colorGrading?: IColorGradingConfiguration;
- environmentRotationY?: number;
- glow?: boolean | BABYLON.IGlowLayerOptions;
- disableHdr?: boolean;
- renderInBackground?: boolean;
- disableCameraControl?: boolean;
- animationPropertiesOverride?: {
- [propName: string]: any;
- };
- defaultMaterial?: {
- materialType: "standard" | "pbr";
- [propName: string]: any;
- };
- flags?: {
- shadowsEnabled?: boolean;
- particlesEnabled?: boolean;
- collisionsEnabled?: boolean;
- lightsEnabled?: boolean;
- texturesEnabled?: boolean;
- lensFlaresEnabled?: boolean;
- proceduralTexturesEnabled?: boolean;
- renderTargetsEnabled?: boolean;
- spritesEnabled?: boolean;
- skeletonsEnabled?: boolean;
- audioEnabled?: boolean;
- };
- }
- /**
- * The Color Grading Configuration groups the different settings used to define the color grading used in the viewer.
- */
- export interface IColorGradingConfiguration {
- /**
- * Transform data string, encoded as determined by transformDataFormat.
- */
- transformData: string;
- /**
- * The encoding format of TransformData (currently only raw-base16 is supported).
- */
- transformDataFormat: string;
- /**
- * The weight of the transform
- */
- transformWeight: number;
- /**
- * Color curve colorFilterHueGlobal value
- */
- colorFilterHueGlobal: number;
- /**
- * Color curve colorFilterHueShadows value
- */
- colorFilterHueShadows: number;
- /**
- * Color curve colorFilterHueMidtones value
- */
- colorFilterHueMidtones: number;
- /**
- * Color curve colorFilterHueHighlights value
- */
- colorFilterHueHighlights: number;
- /**
- * Color curve colorFilterDensityGlobal value
- */
- colorFilterDensityGlobal: number;
- /**
- * Color curve colorFilterDensityShadows value
- */
- colorFilterDensityShadows: number;
- /**
- * Color curve colorFilterDensityMidtones value
- */
- colorFilterDensityMidtones: number;
- /**
- * Color curve colorFilterDensityHighlights value
- */
- colorFilterDensityHighlights: number;
- /**
- * Color curve saturationGlobal value
- */
- saturationGlobal: number;
- /**
- * Color curve saturationShadows value
- */
- saturationShadows: number;
- /**
- * Color curve saturationMidtones value
- */
- saturationMidtones: number;
- /**
- * Color curve saturationHighlights value
- */
- saturationHighlights: number;
- /**
- * Color curve exposureGlobal value
- */
- exposureGlobal: number;
- /**
- * Color curve exposureShadows value
- */
- exposureShadows: number;
- /**
- * Color curve exposureMidtones value
- */
- exposureMidtones: number;
- /**
- * Color curve exposureHighlights value
- */
- exposureHighlights: number;
- }
- export interface ISceneOptimizerConfiguration {
- targetFrameRate?: number;
- trackerDuration?: number;
- autoGeneratePriorities?: boolean;
- improvementMode?: boolean;
- degradation?: string;
- types?: {
- texture?: ISceneOptimizerParameters;
- hardwareScaling?: ISceneOptimizerParameters;
- shadow?: ISceneOptimizerParameters;
- postProcess?: ISceneOptimizerParameters;
- lensFlare?: ISceneOptimizerParameters;
- particles?: ISceneOptimizerParameters;
- renderTarget?: ISceneOptimizerParameters;
- mergeMeshes?: ISceneOptimizerParameters;
- };
- custom?: string;
- }
- export interface IObserversConfiguration {
- onEngineInit?: string;
- onSceneInit?: string;
- onModelLoaded?: string;
- }
- export interface ICameraConfiguration {
- position?: {
- x: number;
- y: number;
- z: number;
- };
- rotation?: {
- x: number;
- y: number;
- z: number;
- w: number;
- };
- fov?: number;
- fovMode?: number;
- minZ?: number;
- maxZ?: number;
- inertia?: number;
- exposure?: number;
- pinchPrecision?: number;
- behaviors?: {
- [name: string]: number | {
- type: number;
- [propName: string]: any;
- };
- };
- disableCameraControl?: boolean;
- disableCtrlForPanning?: boolean;
- disableAutoFocus?: boolean;
- [propName: string]: any;
- }
- export interface ILightConfiguration {
- type: number;
- name?: string;
- disabled?: boolean;
- position?: {
- x: number;
- y: number;
- z: number;
- };
- target?: {
- x: number;
- y: number;
- z: number;
- };
- direction?: {
- x: number;
- y: number;
- z: number;
- };
- diffuse?: {
- r: number;
- g: number;
- b: number;
- };
- specular?: {
- r: number;
- g: number;
- b: number;
- };
- intensity?: number;
- intensityMode?: number;
- radius?: number;
- shadownEnabled?: boolean;
- shadowConfig?: {
- useBlurExponentialShadowMap?: boolean;
- useBlurCloseExponentialShadowMap?: boolean;
- useKernelBlur?: boolean;
- blurKernel?: number;
- blurScale?: number;
- minZ?: number;
- maxZ?: number;
- frustumSize?: number;
- angleScale?: number;
- frustumEdgeFalloff?: number;
- [propName: string]: any;
- };
- spotAngle?: number;
- shadowFieldOfView?: number;
- shadowBufferSize?: number;
- shadowFrustumSize?: number;
- shadowMinZ?: number;
- shadowMaxZ?: number;
- [propName: string]: any;
- behaviors?: {
- [name: string]: number | {
- type: number;
- [propName: string]: any;
- };
- };
- }
- export interface ISceneOptimizerParameters {
- priority?: number;
- maximumSize?: number;
- step?: number;
- }
- export interface IImageProcessingConfiguration {
- colorGradingEnabled?: boolean;
- colorCurvesEnabled?: boolean;
- colorCurves?: {
- globalHue?: number;
- globalDensity?: number;
- globalSaturation?: number;
- globalExposure?: number;
- highlightsHue?: number;
- highlightsDensity?: number;
- highlightsSaturation?: number;
- highlightsExposure?: number;
- midtonesHue?: number;
- midtonesDensity?: number;
- midtonesSaturation?: number;
- midtonesExposure?: number;
- shadowsHue?: number;
- shadowsDensity?: number;
- shadowsSaturation?: number;
- shadowsExposure?: number;
- };
- colorGradingWithGreenDepth?: boolean;
- colorGradingBGR?: boolean;
- exposure?: number;
- toneMappingEnabled?: boolean;
- contrast?: number;
- vignetteEnabled?: boolean;
- vignetteStretch?: number;
- vignetteCentreX?: number;
- vignetteCentreY?: number;
- vignetteWeight?: number;
- vignetteColor?: {
- r: number;
- g: number;
- b: number;
- a?: number;
- };
- vignetteCameraFov?: number;
- vignetteBlendMode?: number;
- vignetteM?: boolean;
- applyByPostProcess?: boolean;
- isEnabled?: boolean;
- }
- }
- declare module BabylonViewer {
-
- /**
- * A single template configuration object
- */
- export interface ITemplateConfiguration {
- /**
- * can be either the id of the template's html element or a URL.
- * See - http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
- */
- location?: string;
- /**
- * If no location is provided you can provide here the raw html of this template.
- * See http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
- */
- html?: string;
- id?: string;
- /**
- * Parameters that will be delivered to the template and will render it accordingly.
- */
- params?: {
- [key: string]: string | number | boolean | object;
- };
- /**
- * Events to attach to this template.
- * event name is the key. the value can either be a boolean (attach to the parent element)
- * or a map of html id elements.
- *
- * See - http://doc.babylonjs.com/extensions/the_templating_system#event-binding
- */
- events?: {
- pointerdown?: boolean | {
- [id: string]: boolean;
- };
- pointerup?: boolean | {
- [id: string]: boolean;
- };
- pointermove?: boolean | {
- [id: string]: boolean;
- };
- pointerover?: boolean | {
- [id: string]: boolean;
- };
- pointerout?: boolean | {
- [id: string]: boolean;
- };
- pointerenter?: boolean | {
- [id: string]: boolean;
- };
- pointerleave?: boolean | {
- [id: string]: boolean;
- };
- pointercancel?: boolean | {
- [id: string]: boolean;
- };
- click?: boolean | {
- [id: string]: boolean;
- };
- dragstart?: boolean | {
- [id: string]: boolean;
- };
- drop?: boolean | {
- [id: string]: boolean;
- };
- [key: string]: boolean | {
- [id: string]: boolean;
- } | undefined;
- };
- }
- /**
- * The object sent when an event is triggered
- */
- export interface EventCallback {
- event: Event;
- template: Template;
- selector: string;
- payload?: any;
- }
- /**
- * The template manager, a member of the viewer class, will manage the viewer's templates and generate the HTML.
- * The template manager managers a single viewer and can be seen as the collection of all sub-templates of the viewer.
- */
- export class TemplateManager {
- containerElement: HTMLElement;
- /**
- * Will be triggered when any template is initialized
- */
- onTemplateInit: BABYLON.Observable<Template>;
- /**
- * Will be triggered when any template is fully loaded
- */
- onTemplateLoaded: BABYLON.Observable<Template>;
- /**
- * Will be triggered when a template state changes
- */
- onTemplateStateChange: BABYLON.Observable<Template>;
- /**
- * Will be triggered when all templates finished loading
- */
- onAllLoaded: BABYLON.Observable<TemplateManager>;
- /**
- * Will be triggered when any event on any template is triggered.
- */
- onEventTriggered: BABYLON.Observable<EventCallback>;
- /**
- * This template manager's event manager. In charge of callback registrations to native event types
- */
- eventManager: EventManager;
- constructor(containerElement: HTMLElement);
- /**
- * Initialize the template(s) for the viewer. Called bay the Viewer class
- * @param templates the templates to be used to initialize the main template
- */
- initTemplate(templates: {
- [key: string]: ITemplateConfiguration;
- }): Promise<void>;
- /**
- * Get the canvas in the template tree.
- * There must be one and only one canvas inthe template.
- */
- getCanvas(): HTMLCanvasElement | null;
- /**
- * Get a specific template from the template tree
- * @param name the name of the template to load
- */
- getTemplate(name: string): Template | undefined;
- /**
- * Dispose the template manager
- */
- dispose(): void;
- }
-
- /**
- * This class represents a single template in the viewer's template tree.
- * An example for a template is a single canvas, an overlay (containing sub-templates) or the navigation bar.
- * A template is injected using the template manager in the correct position.
- * The template is rendered using Handlebars and can use Handlebars' features (such as parameter injection)
- *
- * For further information please refer to the documentation page, https://doc.babylonjs.com
- */
- export class Template {
- name: string;
- /**
- * Will be triggered when the template is loaded
- */
- onLoaded: BABYLON.Observable<Template>;
- /**
- * will be triggered when the template is appended to the tree
- */
- onAppended: BABYLON.Observable<Template>;
- /**
- * Will be triggered when the template's state changed (shown, hidden)
- */
- onStateChange: BABYLON.Observable<Template>;
- /**
- * Will be triggered when an event is triggered on ths template.
- * The event is a native browser event (like mouse or pointer events)
- */
- onEventTriggered: BABYLON.Observable<EventCallback>;
- /**
- * is the template loaded?
- */
- isLoaded: boolean;
- /**
- * This is meant to be used to track the show and hide functions.
- * This is NOT (!!) a flag to check if the element is actually visible to the user.
- */
- isShown: boolean;
- /**
- * Is this template a part of the HTML tree (the template manager injected it)
- */
- isInHtmlTree: boolean;
- /**
- * The HTML element containing this template
- */
- parent: HTMLElement;
- /**
- * A promise that is fulfilled when the template finished loading.
- */
- initPromise: Promise<Template>;
- constructor(name: string, _configuration: ITemplateConfiguration);
- /**
- * Some templates have parameters (like background color for example).
- * The parameters are provided to Handlebars which in turn generates the template.
- * This function will update the template with the new parameters
- *
- * Note that when updating parameters the events will be registered again (after being cleared).
- *
- * @param params the new template parameters
- */
- updateParams(params: {
- [key: string]: string | number | boolean | object;
- }, append?: boolean): void;
- /**
- * Get the template'S configuration
- */
- readonly configuration: ITemplateConfiguration;
- /**
- * A template can be a parent element for other templates or HTML elements.
- * This function will deliver all child HTML elements of this template.
- */
- getChildElements(): Array<string>;
- /**
- * Appending the template to a parent HTML element.
- * If a parent is already set and you wish to replace the old HTML with new one, forceRemove should be true.
- * @param parent the parent to which the template is added
- * @param forceRemove if the parent already exists, shoud the template be removed from it?
- */
- appendTo(parent: HTMLElement, forceRemove?: boolean): void;
- /**
- * Show the template using the provided visibilityFunction, or natively using display: flex.
- * The provided function returns a promise that should be fullfilled when the element is shown.
- * Since it is a promise async operations are more than possible.
- * See the default viewer for an opacity example.
- * @param visibilityFunction The function to execute to show the template.
- */
- show(visibilityFunction?: (template: Template) => Promise<Template>): Promise<Template>;
- /**
- * Hide the template using the provided visibilityFunction, or natively using display: none.
- * The provided function returns a promise that should be fullfilled when the element is hidden.
- * Since it is a promise async operations are more than possible.
- * See the default viewer for an opacity example.
- * @param visibilityFunction The function to execute to show the template.
- */
- hide(visibilityFunction?: (template: Template) => Promise<Template>): Promise<Template>;
- /**
- * Dispose this template
- */
- dispose(): void;
- }
- }
- declare module BabylonViewer {
-
-
-
-
-
- /**
- * This interface describes the structure of the variable sent with the configuration observables of the scene manager.
- * O - the type of object we are dealing with (Light, BABYLON.ArcRotateCamera, BABYLON.Scene, etc')
- * T - the configuration type
- */
- export interface IPostConfigurationCallback<OBJ, CONF> {
- newConfiguration: CONF;
- sceneManager: SceneManager;
- object: OBJ;
- model?: ViewerModel;
- }
- export class SceneManager {
- /**
- * Will notify when the scene was initialized
- */
- onSceneInitObservable: BABYLON.Observable<BABYLON.Scene>;
- /**
- * Will notify after the scene was configured. Can be used to further configure the scene
- */
- onSceneConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.Scene, ISceneConfiguration>>;
- /**
- * Will notify after the scene optimized was configured. Can be used to further configure the scene optimizer
- */
- onSceneOptimizerConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.SceneOptimizer, ISceneOptimizerConfiguration | boolean>>;
- /**
- * Will notify after the camera was configured. Can be used to further configure the camera
- */
- onCameraConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.ArcRotateCamera, ICameraConfiguration>>;
- /**
- * Will notify after the lights were configured. Can be used to further configure lights
- */
- onLightsConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<Array<BABYLON.Light>, {
- [name: string]: ILightConfiguration | boolean;
- }>>;
- /**
- * Will notify after the model(s) were configured. Can be used to further configure models
- */
- onModelsConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<Array<ViewerModel>, IModelConfiguration>>;
- /**
- * Will notify after the envirnoment was configured. Can be used to further configure the environment
- */
- onEnvironmentConfiguredObservable: BABYLON.Observable<IPostConfigurationCallback<BABYLON.EnvironmentHelper, {
- skybox?: ISkyboxConfiguration | boolean;
- ground?: IGroundConfiguration | boolean;
- }>>;
- /**
- * The Babylon BABYLON.Scene of this viewer
- */
- scene: BABYLON.Scene;
- /**
- * The camera used in this viewer
- */
- camera: BABYLON.ArcRotateCamera;
- /**
- * Babylon's scene optimizer
- */
- sceneOptimizer: BABYLON.SceneOptimizer;
- /**
- * Models displayed in this viewer.
- */
- models: Array<ViewerModel>;
- /**
- * Babylon's environment helper of this viewer
- */
- environmentHelper: BABYLON.EnvironmentHelper;
- protected _defaultHighpTextureType: number;
- protected _shadowGeneratorBias: number;
- protected _defaultPipelineTextureType: number;
- /**
- * The maximum number of shadows supported by the curent viewer
- */
- protected _maxShadows: number;
- /**
- * The labs variable consists of objects that will have their API change.
- * Please be careful when using labs in production.
- */
- labs: ViewerLabs;
- readonly defaultRenderingPipeline: BABYLON.Nullable<BABYLON.DefaultRenderingPipeline>;
- constructor(_viewer: AbstractViewer);
- /**
- * Returns a boolean representing HDR support
- */
- readonly isHdrSupported: boolean;
- /**
- * Return the main color defined in the configuration.
- */
- readonly mainColor: BABYLON.Color3;
- readonly reflectionColor: BABYLON.Color3;
- animationBlendingEnabled: boolean;
- /**
- * Should shadows be rendered every frame, or only once and stop.
- * This can be used to optimize a scene.
- *
- * Not that the shadows will NOT disapear but will remain in place.
- * @param process if true shadows will be updated once every frame. if false they will stop being updated.
- */
- processShadows: boolean;
- groundEnabled: boolean;
- /**
- * sets wether the reflection is disabled.
- */
- groundMirrorEnabled: boolean;
- defaultRenderingPipelineEnabled: boolean;
- /**
- * Sets the engine flags to unlock all babylon features.
- * Can also be configured using the scene.flags configuration object
- */
- unlockBabylonFeatures(): void;
- /**
- * initialize the scene. Calling this function again will dispose the old scene, if exists.
- */
- initScene(sceneConfiguration?: ISceneConfiguration, optimizerConfiguration?: boolean | ISceneOptimizerConfiguration): Promise<BABYLON.Scene>;
- clearScene(clearModels?: boolean, clearLights?: boolean): void;
- /**
- * This will update the scene's configuration, including camera, lights, environment.
- * @param newConfiguration the delta that should be configured. This includes only the changes
- * @param globalConfiguration The global configuration object, after the new configuration was merged into it
- */
- updateConfiguration(newConfiguration: Partial<ViewerConfiguration>, globalConfiguration: ViewerConfiguration): void;
- bloomEnabled: boolean;
- fxaaEnabled: boolean;
- /**
- * internally configure the scene using the provided configuration.
- * The scene will not be recreated, but just updated.
- * @param sceneConfig the (new) scene configuration
- */
- protected _configureScene(sceneConfig: ISceneConfiguration): void;
- /**
- * Configure the scene optimizer.
- * The existing scene optimizer will be disposed and a new one will be created.
- * @param optimizerConfig the (new) optimizer configuration
- */
- protected _configureOptimizer(optimizerConfig: ISceneOptimizerConfiguration | boolean): void;
- /**
- * (Re) configure the camera. The camera will only be created once and from this point will only be reconfigured.
- * @param cameraConfig the new camera configuration
- * @param model optionally use the model to configure the camera.
- */
- protected _configureCamera(cameraConfig?: ICameraConfiguration): void;
- protected _configureEnvironment(skyboxConifguration?: ISkyboxConfiguration | boolean, groundConfiguration?: IGroundConfiguration | boolean): Promise<BABYLON.Scene> | undefined;
- /**
- * configure the lights.
- *
- * @param lightsConfiguration the (new) light(s) configuration
- * @param model optionally use the model to configure the camera.
- */
- protected _configureLights(lightsConfiguration?: {
- [name: string]: ILightConfiguration | boolean;
- }): void;
- /**
- * Gets the shadow map blur kernel according to the light configuration.
- * @param light The light used to generate the shadows
- * @param bufferSize The size of the shadow map
- * @return the kernel blur size
- */
- getBlurKernel(light: BABYLON.IShadowLight, bufferSize: number): number;
- /**
- * Alters render settings to reduce features based on hardware feature limitations
- * @param enableHDR Allows the viewer to run in HDR mode.
- */
- protected _handleHardwareLimitations(enableHDR?: boolean): void;
- /**
- * Dispoe the entire viewer including the scene and the engine
- */
- dispose(): void;
- }
- }
- declare module BabylonViewer {
-
- /**
- * The configuration loader will load the configuration object from any source and will use the defined mapper to
- * parse the object and return a conform ViewerConfiguration.
- * It is a private member of the scene.
- */
- export class ConfigurationLoader {
- constructor(_enableCache?: boolean);
- /**
- * load a configuration object that is defined in the initial configuration provided.
- * The viewer configuration can extend different types of configuration objects and have an extra configuration defined.
- *
- * @param initConfig the initial configuration that has the definitions of further configuration to load.
- * @param callback an optional callback that will be called sync, if noconfiguration needs to be loaded or configuration is payload-only
- * @returns A promise that delivers the extended viewer configuration, when done.
- */
- loadConfiguration(initConfig?: ViewerConfiguration, callback?: (config: ViewerConfiguration) => void): Promise<ViewerConfiguration>;
- /**
- * Dispose the configuration loader. This will cancel file requests, if active.
- */
- dispose(): void;
- }
- }
- declare module BabylonViewer {
-
- /**
- * The EventManager is in charge of registering user interctions with the viewer.
- * It is used in the TemplateManager
- */
- export class EventManager {
- constructor(_templateManager: TemplateManager);
- /**
- * Register a new callback to a specific template.
- * The best example for the usage can be found in the DefaultViewer
- *
- * @param templateName the templateName to register the event to
- * @param callback The callback to be executed
- * @param eventType the type of event to register
- * @param selector an optional selector. if not defined the parent object in the template will be selected
- */
- registerCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
- /**
- * This will remove a registered event from the defined template.
- * Each one of the variables apart from the template name are optional, but one must be provided.
- *
- * @param templateName the templateName
- * @param callback the callback to remove (optional)
- * @param eventType the event type to remove (optional)
- * @param selector the selector from which to remove the event (optional)
- */
- unregisterCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
- /**
- * Dispose the event manager
- */
- dispose(): void;
- }
- }
- declare module BabylonViewer {
-
-
- /**
- * The ViewerLabs class will hold functions that are not (!) backwards compatible.
- * The APIs in all labs-related classes and configuration might change.
- * Once stable, lab features will be moved to the publis API and configuration object.
- */
- export class ViewerLabs {
- constructor(_sceneManager: SceneManager);
- assetsRootURL: string;
- environment: PBREnvironment;
- /**
- * Loads an environment map from a given URL
- * @param url URL of environment map
- * @param onSuccess Callback fired after environment successfully applied to the scene
- * @param onProgress Callback fired at progress events while loading the environment map
- * @param onError Callback fired when the load fails
- */
- loadEnvironment(url: string, onSuccess?: (env: PBREnvironment) => void, onProgress?: (bytesLoaded: number, bytesTotal: number) => void, onError?: (e: any) => void): void;
- /**
- * Loads an environment map from a given URL
- * @param buffer ArrayBuffer containing environment map
- * @param onSuccess Callback fired after environment successfully applied to the scene
- * @param onProgress Callback fired at progress events while loading the environment map
- * @param onError Callback fired when the load fails
- */
- loadEnvironment(buffer: ArrayBuffer, onSuccess?: (env: PBREnvironment) => void, onProgress?: (bytesLoaded: number, bytesTotal: number) => void, onError?: (e: any) => void): void;
- /**
- * Sets the environment to an already loaded environment
- * @param env PBREnvironment instance
- * @param onSuccess Callback fired after environment successfully applied to the scene
- * @param onProgress Callback fired at progress events while loading the environment map
- * @param onError Callback fired when the load fails
- */
- loadEnvironment(env: PBREnvironment, onSuccess?: (env: PBREnvironment) => void, onProgress?: (bytesLoaded: number, bytesTotal: number) => void, onError?: (e: any) => void): void;
- /**
- * Applies an `EnvironmentMapConfiguration` to the scene
- * @param environmentMapConfiguration Environment map configuration to apply
- */
- applyEnvironmentMapConfiguration(rotationY?: number): void;
- /**
- * Get an environment asset url by using the configuration if the path is not absolute.
- * @param url Asset url
- * @returns The Asset url using the `environmentAssetsRootURL` if the url is not an absolute path.
- */
- getAssetUrl(url: string): string;
- }
- }
- declare module BabylonViewer {
-
-
- /**
- * Spherical polynomial coefficients (counter part to spherical harmonic coefficients used in shader irradiance calculation)
- * @ignoreChildren
- */
- export interface SphericalPolynomalCoefficients {
- x: BABYLON.Vector3;
- y: BABYLON.Vector3;
- z: BABYLON.Vector3;
- xx: BABYLON.Vector3;
- yy: BABYLON.Vector3;
- zz: BABYLON.Vector3;
- yz: BABYLON.Vector3;
- zx: BABYLON.Vector3;
- xy: BABYLON.Vector3;
- }
- /**
- * Wraps data and maps required for environments with physically based rendering
- */
- export interface PBREnvironment {
- /**
- * Spherical Polynomial Coefficients representing an irradiance map
- */
- irradiancePolynomialCoefficients: SphericalPolynomalCoefficients;
- /**
- * Specular cubemap
- */
- specularTexture?: TextureCube;
- /**
- * A scale factor applied to RGB values after reading from environment maps
- */
- textureIntensityScale: number;
- }
- /**
- * Environment map representations: layouts, projections and approximations
- */
- export type MapType = 'irradiance_sh_coefficients_9' | 'cubemap_faces';
- /**
- * Image type used for environment map
- */
- export type ImageType = 'png';
- /**
- * A generic field in JSON that report's its type
- */
- export interface TypedObject<T> {
- type: T;
- }
- /**
- * Describes a range of bytes starting at byte pos (inclusive) and finishing at byte pos + length - 1
- */
- export interface ByteRange {
- pos: number;
- length: number;
- }
- /**
- * Complete Spectre Environment JSON Descriptor
- */
- export interface EnvJsonDescriptor {
- radiance: TypedObject<MapType>;
- irradiance: TypedObject<MapType>;
- specular: TypedObject<MapType>;
- }
- /**
- * Spherical harmonic coefficients to provide an irradiance map
- */
- export interface IrradianceSHCoefficients9 extends TypedObject<MapType> {
- l00: Array<number>;
- l1_1: Array<number>;
- l10: Array<number>;
- l11: Array<number>;
- l2_2: Array<number>;
- l2_1: Array<number>;
- l20: Array<number>;
- l21: Array<number>;
- l22: Array<number>;
- }
- /**
- * A generic set of images, where the image content is specified by byte ranges in the mipmaps field
- */
- export interface ImageSet<T> extends TypedObject<MapType> {
- imageType: ImageType;
- width: number;
- height: number;
- mipmaps: Array<T>;
- multiplier: number;
- }
- /**
- * A set of cubemap faces
- */
- export type CubemapFaces = ImageSet<Array<ByteRange>>;
- /**
- * A single image containing an atlas of equirectangular-projection maps across all mip levels
- */
- export type EquirectangularMipmapAtlas = ImageSet<ByteRange>;
- /**
- * A static class proving methods to aid parsing Spectre environment files
- */
- export class EnvironmentDeserializer {
- /**
- * Parses an arraybuffer into a new PBREnvironment object
- * @param arrayBuffer The arraybuffer of the Spectre environment file
- * @return a PBREnvironment object
- */
- static Parse(arrayBuffer: ArrayBuffer): PBREnvironment;
- }
- }
- declare module BabylonViewer {
- /**
- * WebGL Pixel Formats
- */
- export const enum PixelFormat {
- DEPTH_COMPONENT = 6402,
- ALPHA = 6406,
- RGB = 6407,
- RGBA = 6408,
- LUMINANCE = 6409,
- LUMINANCE_ALPHA = 6410,
- }
- /**
- * WebGL Pixel Types
- */
- export const enum PixelType {
- UNSIGNED_BYTE = 5121,
- UNSIGNED_SHORT_4_4_4_4 = 32819,
- UNSIGNED_SHORT_5_5_5_1 = 32820,
- UNSIGNED_SHORT_5_6_5 = 33635,
- }
- /**
- * WebGL Texture Magnification Filter
- */
- export const enum TextureMagFilter {
- NEAREST = 9728,
- LINEAR = 9729,
- }
- /**
- * WebGL Texture Minification Filter
- */
- export const enum TextureMinFilter {
- NEAREST = 9728,
- LINEAR = 9729,
- NEAREST_MIPMAP_NEAREST = 9984,
- LINEAR_MIPMAP_NEAREST = 9985,
- NEAREST_MIPMAP_LINEAR = 9986,
- LINEAR_MIPMAP_LINEAR = 9987,
- }
- /**
- * WebGL Texture Wrap Modes
- */
- export const enum TextureWrapMode {
- REPEAT = 10497,
- CLAMP_TO_EDGE = 33071,
- MIRRORED_REPEAT = 33648,
- }
- /**
- * Raw texture data and descriptor sufficient for WebGL texture upload
- */
- export interface TextureData {
- /**
- * Width of image
- */
- width: number;
- /**
- * Height of image
- */
- height: number;
- /**
- * Format of pixels in data
- */
- format: PixelFormat;
- /**
- * Row byte alignment of pixels in data
- */
- alignment: number;
- /**
- * Pixel data
- */
- data: ArrayBufferView;
- }
- /**
- * Wraps sampling parameters for a WebGL texture
- */
- export interface SamplingParameters {
- /**
- * Magnification mode when upsampling from a WebGL texture
- */
- magFilter?: TextureMagFilter;
- /**
- * Minification mode when upsampling from a WebGL texture
- */
- minFilter?: TextureMinFilter;
- /**
- * X axis wrapping mode when sampling out of a WebGL texture bounds
- */
- wrapS?: TextureWrapMode;
- /**
- * Y axis wrapping mode when sampling out of a WebGL texture bounds
- */
- wrapT?: TextureWrapMode;
- /**
- * Anisotropic filtering samples
- */
- maxAnisotropy?: number;
- }
- /**
- * Represents a valid WebGL texture source for use in texImage2D
- */
- export type TextureSource = TextureData | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;
- /**
- * A generic set of texture mipmaps (where index 0 has the largest dimension)
- */
- export type Mipmaps<T> = Array<T>;
- /**
- * A set of 6 cubemap arranged in the order [+x, -x, +y, -y, +z, -z]
- */
- export type Faces<T> = Array<T>;
- /**
- * A set of texture mipmaps specifically for 2D textures in WebGL (where index 0 has the largest dimension)
- */
- export type Mipmaps2D = Mipmaps<TextureSource>;
- /**
- * A set of texture mipmaps specifically for cubemap textures in WebGL (where index 0 has the largest dimension)
- */
- export type MipmapsCube = Mipmaps<Faces<TextureSource>>;
- /**
- * A minimal WebGL cubemap descriptor
- */
- export class TextureCube {
- internalFormat: PixelFormat;
- type: PixelType;
- source: MipmapsCube;
- /**
- * Returns the width of a face of the texture or 0 if not available
- */
- readonly Width: number;
- /**
- * Returns the height of a face of the texture or 0 if not available
- */
- readonly Height: number;
- /**
- * constructor
- * @param internalFormat WebGL pixel format for the texture on the GPU
- * @param type WebGL pixel type of the supplied data and texture on the GPU
- * @param source An array containing mipmap levels of faces, where each mipmap level is an array of faces and each face is a TextureSource object
- */
- constructor(internalFormat: PixelFormat, type: PixelType, source?: MipmapsCube);
- }
- /**
- * A static class providing methods to aid working with Bablyon textures.
- */
- export class TextureUtils {
- /**
- * A prefix used when storing a babylon texture object reference on a Spectre texture object
- */
- static BabylonTextureKeyPrefix: string;
- /**
- * Controls anisotropic filtering for deserialized textures.
- */
- static MaxAnisotropy: number;
- /**
- * Returns a BabylonCubeTexture instance from a Spectre texture cube, subject to sampling parameters.
- * If such a texture has already been requested in the past, this texture will be returned, otherwise a new one will be created.
- * The advantage of this is to enable working with texture objects without the need to initialize on the GPU until desired.
- * @param scene A Babylon BABYLON.Scene instance
- * @param textureCube A Spectre TextureCube object
- * @param parameters WebGL texture sampling parameters
- * @param automaticMipmaps Pass true to enable automatic mipmap generation where possible (requires power of images)
- * @param environment Specifies that the texture will be used as an environment
- * @param singleLod Specifies that the texture will be a singleLod (for environment)
- * @return Babylon cube texture
- */
- static GetBabylonCubeTexture(scene: BABYLON.Scene, textureCube: TextureCube, automaticMipmaps: boolean, environment?: boolean, singleLod?: boolean): BABYLON.CubeTexture;
- /**
- * Applies Spectre SamplingParameters to a Babylon texture by directly setting texture parameters on the internal WebGLTexture as well as setting Babylon fields
- * @param babylonTexture Babylon texture to apply texture to (requires the Babylon texture has an initialize _texture field)
- * @param parameters Spectre SamplingParameters to apply
- */
- static ApplySamplingParameters(babylonTexture: BABYLON.BaseTexture, parameters: SamplingParameters): void;
- /**
- * Environment preprocessing dedicated value (Internal Use or Advanced only).
- */
- static EnvironmentLODScale: number;
- /**
- * Environment preprocessing dedicated value (Internal Use or Advanced only)..
- */
- static EnvironmentLODOffset: number;
- }
- }
|