|
@@ -566,7 +566,169 @@ declare module 'babylonjs-viewer/loader/modelLoader' {
|
|
|
}
|
|
|
|
|
|
declare module 'babylonjs-viewer/model/viewerModel' {
|
|
|
-
|
|
|
+ import { ISceneLoaderPlugin, ISceneLoaderPluginAsync, AnimationGroup, AbstractMesh, Observable, SceneLoaderProgressEvent, IParticleSystem, Skeleton, IDisposable, Nullable, Animation, Material } from "babylonjs";
|
|
|
+ import { GLTF2 } from "babylonjs-loaders";
|
|
|
+ import { IModelConfiguration } from "babylonjs-viewer/configuration/interfaces/modelConfiguration";
|
|
|
+ import { IModelAnimation } from "babylonjs-viewer/model/modelAnimation";
|
|
|
+ import { ObservablesManager } from "babylonjs-viewer/managers/observablesManager";
|
|
|
+ import { ConfigurationContainer } from "babylonjs-viewer/configuration/configurationContainer";
|
|
|
+ /**
|
|
|
+ * 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 IDisposable {
|
|
|
+ /**
|
|
|
+ * The loader used to load this model.
|
|
|
+ */
|
|
|
+ loader: ISceneLoaderPlugin | ISceneLoaderPluginAsync;
|
|
|
+ /**
|
|
|
+ * This model's root mesh (the parent of all other meshes).
|
|
|
+ * This mesh does not(!) exist in the meshes array.
|
|
|
+ */
|
|
|
+ rootMesh: AbstractMesh;
|
|
|
+ /**
|
|
|
+ * ParticleSystems connected to this model
|
|
|
+ */
|
|
|
+ particleSystems: Array<IParticleSystem>;
|
|
|
+ /**
|
|
|
+ * Skeletons defined in this model
|
|
|
+ */
|
|
|
+ skeletons: Array<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: Observable<ViewerModel>;
|
|
|
+ /**
|
|
|
+ * Observers registered here will be executed when the loader notified of a progress event
|
|
|
+ */
|
|
|
+ onLoadProgressObservable: Observable<SceneLoaderProgressEvent>;
|
|
|
+ /**
|
|
|
+ * Observers registered here will be executed when the loader notified of an error.
|
|
|
+ */
|
|
|
+ onLoadErrorObservable: Observable<{
|
|
|
+ message: string;
|
|
|
+ exception: any;
|
|
|
+ }>;
|
|
|
+ /**
|
|
|
+ * Will be executed after the model finished loading and complete, including entry animation and lod
|
|
|
+ */
|
|
|
+ onCompleteObservable: 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: 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: GLTF2.IAsset;
|
|
|
+ constructor(_observablesManager: ObservablesManager, modelConfiguration: IModelConfiguration, _configurationContainer?: ConfigurationContainer | undefined);
|
|
|
+ shadowsRenderedAfterLoad: boolean;
|
|
|
+ getViewerId(): string | undefined;
|
|
|
+ /**
|
|
|
+ * Set whether this model is enabled or not.
|
|
|
+ */
|
|
|
+ enabled: boolean;
|
|
|
+ loaderDone: boolean;
|
|
|
+ /**
|
|
|
+ * 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: AbstractMesh, triggerLoaded?: boolean): Promise<ViewerModel> | undefined;
|
|
|
+ /**
|
|
|
+ * get the list of meshes (excluding the root mesh)
|
|
|
+ */
|
|
|
+ readonly meshes: 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: 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): 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 Material to apply configuration to
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
+ _applyModelMaterialConfiguration(material: 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: 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 'babylonjs-viewer/model/modelAnimation' {
|
|
@@ -1121,15 +1283,7 @@ declare module 'babylonjs-viewer/templating/templateManager' {
|
|
|
}
|
|
|
|
|
|
declare module 'babylonjs-viewer/configuration/configurationContainer' {
|
|
|
- import { ViewerConfiguration } from 'babylonjs-viewer/configuration/configuration';
|
|
|
- import { Color3, Scene } from 'babylonjs';
|
|
|
- export class ConfigurationContainer {
|
|
|
- configuration: ViewerConfiguration;
|
|
|
- viewerId: string;
|
|
|
- mainColor: Color3;
|
|
|
- reflectionColor: Color3;
|
|
|
- scene?: Scene;
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
declare module 'babylonjs-viewer/configuration/loader' {
|