viewer.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. import { viewerManager } from './viewerManager';
  2. import { SceneManager } from '../managers/sceneManager';
  3. import { ConfigurationLoader } from '../configuration/loader';
  4. import { Skeleton, AnimationGroup, ParticleSystem, CubeTexture, Color3, IEnvironmentHelperOptions, EnvironmentHelper, Effect, SceneOptimizer, SceneOptimizerOptions, Observable, Engine, Scene, ArcRotateCamera, Vector3, SceneLoader, AbstractMesh, Mesh, HemisphericLight, Database, SceneLoaderProgressEvent, ISceneLoaderPlugin, ISceneLoaderPluginAsync, Quaternion, Light, ShadowLight, ShadowGenerator, Tags, AutoRotationBehavior, BouncingBehavior, FramingBehavior, Behavior, Tools, RenderingManager } from 'babylonjs';
  5. import { ViewerConfiguration, ISceneConfiguration, ISceneOptimizerConfiguration, IObserversConfiguration, IModelConfiguration, ISkyboxConfiguration, IGroundConfiguration, ILightConfiguration, ICameraConfiguration } from '../configuration/';
  6. import { ViewerModel } from '../model/viewerModel';
  7. import { GroupModelAnimation } from '../model/modelAnimation';
  8. import { ModelLoader } from '../loader/modelLoader';
  9. import { CameraBehavior } from '../interfaces';
  10. import { viewerGlobals } from '../configuration/globals';
  11. import { extendClassWithConfig } from '../helper';
  12. import { telemetryManager } from '../telemetryManager';
  13. import { deepmerge } from '../helper/';
  14. import { ObservablesManager } from '../managers/observablesManager';
  15. import { ConfigurationContainer } from '../configuration/configurationContainer';
  16. import { TemplateManager } from '../templating/templateManager';
  17. /**
  18. * The AbstractViewr is the center of Babylon's viewer.
  19. * It is the basic implementation of the default viewer and is responsible of loading and showing the model and the templates
  20. */
  21. export abstract class AbstractViewer {
  22. /**
  23. * The corresponsing template manager of this viewer.
  24. */
  25. public templateManager: TemplateManager;
  26. // TODO get the template manager to the default viewer, if no one is extending the abstract viewer
  27. /**
  28. * Babylon Engine corresponding with this viewer
  29. */
  30. public engine: Engine;
  31. /**
  32. * The ID of this viewer. it will be generated randomly or use the HTML Element's ID.
  33. */
  34. public readonly baseId: string;
  35. /**
  36. * The last loader used to load a model.
  37. * @deprecated
  38. */
  39. public lastUsedLoader: ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40. /**
  41. * The ModelLoader instance connected with this viewer.
  42. */
  43. public modelLoader: ModelLoader;
  44. /**
  45. * A flag that controls whether or not the render loop should be executed
  46. */
  47. public runRenderLoop: boolean = true;
  48. /**
  49. * The scene manager connected with this viewer instance
  50. */
  51. public sceneManager: SceneManager;
  52. // observables
  53. /**
  54. * Will notify when the scene was initialized
  55. */
  56. public get onSceneInitObservable(): Observable<Scene> {
  57. return this.observablesManager.onSceneInitObservable;
  58. }
  59. /**
  60. * will notify when the engine was initialized
  61. */
  62. public get onEngineInitObservable(): Observable<Engine> {
  63. return this.observablesManager.onEngineInitObservable;
  64. }
  65. /**
  66. * Will notify when a new model was added to the scene.
  67. * Note that added does not neccessarily mean loaded!
  68. */
  69. public get onModelAddedObservable(): Observable<ViewerModel> {
  70. return this.observablesManager.onModelAddedObservable;
  71. }
  72. /**
  73. * will notify after every model load
  74. */
  75. public get onModelLoadedObservable(): Observable<ViewerModel> {
  76. return this.observablesManager.onModelLoadedObservable;
  77. }
  78. /**
  79. * will notify when any model notify of progress
  80. */
  81. public get onModelLoadProgressObservable(): Observable<SceneLoaderProgressEvent> {
  82. return this.observablesManager.onModelLoadProgressObservable;
  83. }
  84. /**
  85. * will notify when any model load failed.
  86. */
  87. public get onModelLoadErrorObservable(): Observable<{ message: string; exception: any }> {
  88. return this.observablesManager.onModelLoadErrorObservable;
  89. }
  90. /**
  91. * Will notify when a model was removed from the scene;
  92. */
  93. public get onModelRemovedObservable(): Observable<ViewerModel> {
  94. return this.observablesManager.onModelRemovedObservable;
  95. }
  96. /**
  97. * will notify when a new loader was initialized.
  98. * Used mainly to know when a model starts loading.
  99. */
  100. public get onLoaderInitObservable(): Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync> {
  101. return this.observablesManager.onLoaderInitObservable;
  102. }
  103. /**
  104. * Observers registered here will be executed when the entire load process has finished.
  105. */
  106. public get onInitDoneObservable(): Observable<AbstractViewer> {
  107. return this.observablesManager.onViewerInitDoneObservable;
  108. }
  109. /**
  110. * Functions added to this observable will be executed on each frame rendered.
  111. */
  112. public get onFrameRenderedObservable(): Observable<AbstractViewer> {
  113. return this.observablesManager.onFrameRenderedObservable;
  114. }
  115. public observablesManager: ObservablesManager;
  116. /**
  117. * The canvas associated with this viewer
  118. */
  119. protected _canvas: HTMLCanvasElement;
  120. /**
  121. * The (single) canvas of this viewer
  122. */
  123. public get canvas(): HTMLCanvasElement {
  124. return this._canvas;
  125. }
  126. /**
  127. * is this viewer disposed?
  128. */
  129. protected _isDisposed: boolean = false;
  130. /**
  131. * registered onBeforeRender functions.
  132. * This functions are also registered at the native scene. The reference can be used to unregister them.
  133. */
  134. protected _registeredOnBeforeRenderFunctions: Array<() => void>;
  135. /**
  136. * The configuration loader of this viewer
  137. */
  138. protected _configurationLoader: ConfigurationLoader;
  139. /**
  140. * Is the viewer already initialized. for internal use.
  141. */
  142. protected _isInit: boolean;
  143. protected _configurationContainer: ConfigurationContainer;
  144. constructor(public containerElement: HTMLElement, initialConfiguration: ViewerConfiguration = {}) {
  145. // if exists, use the container id. otherwise, generate a random string.
  146. if (containerElement.id) {
  147. this.baseId = containerElement.id;
  148. } else {
  149. this.baseId = containerElement.id = 'bjs' + Math.random().toString(32).substr(2, 8);
  150. }
  151. this._registeredOnBeforeRenderFunctions = [];
  152. this._configurationContainer = new ConfigurationContainer();
  153. // add this viewer to the viewer manager
  154. viewerManager.addViewer(this);
  155. this.observablesManager = new ObservablesManager();
  156. this.modelLoader = new ModelLoader(this.observablesManager, this._configurationContainer);
  157. RenderingManager.AUTOCLEAR = false;
  158. // extend the configuration
  159. this._configurationLoader = new ConfigurationLoader();
  160. this._configurationLoader.loadConfiguration(initialConfiguration, (configuration) => {
  161. this._onConfigurationLoaded(configuration);
  162. });
  163. this.onSceneInitObservable.add(() => {
  164. this.updateConfiguration();
  165. });
  166. this.onInitDoneObservable.add(() => {
  167. this._isInit = true;
  168. this.engine.runRenderLoop(this._render);
  169. });
  170. this._prepareContainerElement();
  171. }
  172. /**
  173. * get the baseId of this viewer
  174. */
  175. public getBaseId(): string {
  176. return this.baseId;
  177. }
  178. /**
  179. * Do we have a canvas to render on, and is it a part of the scene
  180. */
  181. public isCanvasInDOM(): boolean {
  182. return !!this._canvas && !!this._canvas.parentElement;
  183. }
  184. /**
  185. * Is the engine currently set to rende even when the page is in background
  186. */
  187. public get renderInBackground() {
  188. return this.engine && this.engine.renderEvenInBackground;
  189. }
  190. /**
  191. * Set the viewer's background rendering flag.
  192. */
  193. public set renderInBackground(value: boolean) {
  194. if (this.engine) {
  195. this.engine.renderEvenInBackground = value;
  196. }
  197. }
  198. /**
  199. * Get the configuration object. This is a reference only.
  200. * The configuration can ONLY be updated using the updateConfiguration function.
  201. * changing this object will have no direct effect on the scene.
  202. */
  203. public get configuration(): ViewerConfiguration {
  204. return this._configurationContainer.configuration;
  205. }
  206. /**
  207. * force resizing the engine.
  208. */
  209. public forceResize() {
  210. this._resize();
  211. }
  212. /**
  213. * The resize function that will be registered with the window object
  214. */
  215. protected _resize = (): void => {
  216. // Only resize if Canvas is in the DOM
  217. if (!this.isCanvasInDOM()) {
  218. return;
  219. }
  220. if (this.canvas.clientWidth <= 0 || this.canvas.clientHeight <= 0) {
  221. return;
  222. }
  223. if (this.configuration.engine && this.configuration.engine.disableResize) {
  224. return;
  225. }
  226. this.engine.resize();
  227. }
  228. protected _onConfigurationLoaded(configuration: ViewerConfiguration) {
  229. this._configurationContainer.configuration = deepmerge(this.configuration || {}, configuration);
  230. if (this.configuration.observers) {
  231. this._configureObservers(this.configuration.observers);
  232. }
  233. // TODO remove this after testing, as this is done in the updateCOnfiguration as well.
  234. if (this.configuration.loaderPlugins) {
  235. Object.keys(this.configuration.loaderPlugins).forEach((name => {
  236. if (this.configuration.loaderPlugins && this.configuration.loaderPlugins[name]) {
  237. this.modelLoader.addPlugin(name);
  238. }
  239. }))
  240. }
  241. this.templateManager = new TemplateManager(this.containerElement);
  242. }
  243. /**
  244. * Force a single render loop execution.
  245. */
  246. public forceRender() {
  247. this._render(true);
  248. }
  249. /**
  250. * render loop that will be executed by the engine
  251. */
  252. protected _render = (force: boolean = false): void => {
  253. if (force || (this.sceneManager.scene && this.sceneManager.scene.activeCamera)) {
  254. if (this.runRenderLoop || force) {
  255. this.engine.performanceMonitor.enable();
  256. this.sceneManager.scene.render();
  257. this.onFrameRenderedObservable.notifyObservers(this);
  258. } else {
  259. this.engine.performanceMonitor.disable();
  260. // update camera instead of rendering
  261. this.sceneManager.scene.activeCamera && this.sceneManager.scene.activeCamera.update();
  262. }
  263. }
  264. }
  265. /**
  266. * Takes a screenshot of the scene and returns it as a base64 encoded png.
  267. * @param callback optional callback that will be triggered when screenshot is done.
  268. * @param width Optional screenshot width (default to 512).
  269. * @param height Optional screenshot height (default to 512).
  270. * @returns a promise with the screenshot data
  271. */
  272. public takeScreenshot(callback?: (data: string) => void, width = 0, height = 0): Promise<string> {
  273. width = width || this.canvas.clientWidth;
  274. height = height || this.canvas.clientHeight;
  275. // Create the screenshot
  276. return new Promise<string>((resolve, reject) => {
  277. try {
  278. BABYLON.Tools.CreateScreenshot(this.engine, this.sceneManager.camera, { width, height }, (data) => {
  279. if (callback) {
  280. callback(data);
  281. }
  282. resolve(data);
  283. });
  284. } catch (e) {
  285. reject(e);
  286. }
  287. });
  288. }
  289. /**
  290. * Update the current viewer configuration with new values.
  291. * Only provided information will be updated, old configuration values will be kept.
  292. * If this.configuration was manually changed, you can trigger this function with no parameters,
  293. * and the entire configuration will be updated.
  294. * @param newConfiguration the partial configuration to update
  295. *
  296. */
  297. public updateConfiguration(newConfiguration: Partial<ViewerConfiguration> = this.configuration) {
  298. // update this.configuration with the new data
  299. this._configurationContainer.configuration = deepmerge(this.configuration || {}, newConfiguration);
  300. this.sceneManager.updateConfiguration(newConfiguration, this.configuration);
  301. // observers in configuration
  302. if (newConfiguration.observers) {
  303. this._configureObservers(newConfiguration.observers);
  304. }
  305. if (newConfiguration.loaderPlugins) {
  306. Object.keys(newConfiguration.loaderPlugins).forEach((name => {
  307. if (newConfiguration.loaderPlugins && newConfiguration.loaderPlugins[name]) {
  308. this.modelLoader.addPlugin(name);
  309. }
  310. }));
  311. }
  312. }
  313. /**
  314. * this is used to register native functions using the configuration object.
  315. * This will configure the observers.
  316. * @param observersConfiguration observers configuration
  317. */
  318. protected _configureObservers(observersConfiguration: IObserversConfiguration) {
  319. if (observersConfiguration.onEngineInit) {
  320. this.onEngineInitObservable.add(window[observersConfiguration.onEngineInit]);
  321. } else {
  322. if (observersConfiguration.onEngineInit === '' && this.configuration.observers && this.configuration.observers!.onEngineInit) {
  323. this.onEngineInitObservable.removeCallback(window[this.configuration.observers!.onEngineInit!]);
  324. }
  325. }
  326. if (observersConfiguration.onSceneInit) {
  327. this.onSceneInitObservable.add(window[observersConfiguration.onSceneInit]);
  328. } else {
  329. if (observersConfiguration.onSceneInit === '' && this.configuration.observers && this.configuration.observers!.onSceneInit) {
  330. this.onSceneInitObservable.removeCallback(window[this.configuration.observers!.onSceneInit!]);
  331. }
  332. }
  333. if (observersConfiguration.onModelLoaded) {
  334. this.onModelLoadedObservable.add(window[observersConfiguration.onModelLoaded]);
  335. } else {
  336. if (observersConfiguration.onModelLoaded === '' && this.configuration.observers && this.configuration.observers!.onModelLoaded) {
  337. this.onModelLoadedObservable.removeCallback(window[this.configuration.observers!.onModelLoaded!]);
  338. }
  339. }
  340. }
  341. /**
  342. * Dispoe the entire viewer including the scene and the engine
  343. */
  344. public dispose() {
  345. if (this._isDisposed) {
  346. return;
  347. }
  348. window.removeEventListener('resize', this._resize);
  349. if (this.sceneManager) {
  350. if (this.sceneManager.scene && this.sceneManager.scene.activeCamera) {
  351. this.sceneManager.scene.activeCamera.detachControl(this.canvas);
  352. }
  353. this.sceneManager.dispose();
  354. }
  355. this._fpsTimeoutInterval && clearInterval(this._fpsTimeoutInterval);
  356. this.observablesManager.dispose();
  357. this.modelLoader.dispose();
  358. if (this.engine) {
  359. this.engine.dispose();
  360. }
  361. viewerManager.removeViewer(this);
  362. this._isDisposed = true;
  363. }
  364. /**
  365. * This will prepare the container element for the viewer
  366. */
  367. protected abstract _prepareContainerElement();
  368. /**
  369. * This function will execute when the HTML templates finished initializing.
  370. * It should initialize the engine and continue execution.
  371. *
  372. * @returns {Promise<AbstractViewer>} The viewer object will be returned after the object was loaded.
  373. */
  374. protected _onTemplatesLoaded(): Promise<AbstractViewer> {
  375. return Promise.resolve(this);
  376. }
  377. /**
  378. * This will force the creation of an engine and a scene.
  379. * It will also load a model if preconfigured.
  380. * But first - it will load the extendible onTemplateLoaded()!
  381. */
  382. protected _onTemplateLoaded(): Promise<AbstractViewer> {
  383. // check if viewer was disposed right after created
  384. if (this._isDisposed) {
  385. return Promise.reject("viewer was disposed");
  386. }
  387. return this._onTemplatesLoaded().then(() => {
  388. let autoLoad = typeof this.configuration.model === 'string' || (this.configuration.model && this.configuration.model.url);
  389. return this._initEngine().then((engine) => {
  390. return this.onEngineInitObservable.notifyObserversWithPromise(engine);
  391. }).then(() => {
  392. this._initTelemetryEvents();
  393. if (autoLoad) {
  394. return this.loadModel(this.configuration.model!).catch(e => { }).then(() => { return this.sceneManager.scene });
  395. } else {
  396. return this.sceneManager.scene || this.sceneManager.initScene(this.configuration.scene);
  397. }
  398. }).then(() => {
  399. return this.onInitDoneObservable.notifyObserversWithPromise(this);
  400. }).catch(e => {
  401. Tools.Warn(e.toString());
  402. return this;
  403. });
  404. })
  405. }
  406. /**
  407. * Initialize the engine. Retruns a promise in case async calls are needed.
  408. *
  409. * @protected
  410. * @returns {Promise<Engine>}
  411. * @memberof Viewer
  412. */
  413. protected _initEngine(): Promise<Engine> {
  414. // init custom shaders
  415. this._injectCustomShaders();
  416. //let canvasElement = this.templateManager.getCanvas();
  417. if (!this.canvas) {
  418. return Promise.reject('Canvas element not found!');
  419. }
  420. let config = this.configuration.engine || {};
  421. // TDO enable further configuration
  422. // check for webgl2 support, force-disable if needed.
  423. if (viewerGlobals.disableWebGL2Support) {
  424. config.engineOptions = config.engineOptions || {};
  425. config.engineOptions.disableWebGL2Support = true;
  426. }
  427. this.engine = new Engine(this.canvas, !!config.antialiasing, config.engineOptions);
  428. // Disable manifest checking
  429. Database.IDBStorageEnabled = false;
  430. if (!config.disableResize) {
  431. window.addEventListener('resize', this._resize);
  432. }
  433. if (this.configuration.engine && this.configuration.engine.adaptiveQuality) {
  434. var scale = Math.max(0.5, 1 / (window.devicePixelRatio || 2));
  435. this.engine.setHardwareScalingLevel(scale);
  436. }
  437. // create a new template manager for this viewer
  438. this.sceneManager = new SceneManager(this.engine, this.observablesManager);
  439. return Promise.resolve(this.engine);
  440. }
  441. private _isLoading: boolean;
  442. /**
  443. * Initialize a model loading. The returned object (a ViewerModel object) will be loaded in the background.
  444. * The difference between this and loadModel is that loadModel will fulfill the promise when the model finished loading.
  445. *
  446. * @param modelConfig model configuration to use when loading the model.
  447. * @param clearScene should the scene be cleared before loading this model
  448. * @returns a ViewerModel object that is not yet fully loaded.
  449. */
  450. public initModel(modelConfig: string | File | IModelConfiguration, clearScene: boolean = true): ViewerModel {
  451. let configuration: IModelConfiguration;
  452. if (typeof modelConfig === 'string') {
  453. configuration = {
  454. url: modelConfig
  455. }
  456. } else if (modelConfig instanceof File) {
  457. configuration = {
  458. file: modelConfig,
  459. root: "file:"
  460. }
  461. } else {
  462. configuration = modelConfig
  463. }
  464. if (!configuration.url && !configuration.file) {
  465. throw new Error("no model provided");
  466. }
  467. if (clearScene) {
  468. this.sceneManager.clearScene(true, false);
  469. }
  470. //merge the configuration for future models:
  471. if (this.configuration.model && typeof this.configuration.model === 'object') {
  472. let globalConfig = deepmerge({}, this.configuration.model)
  473. configuration = deepmerge(globalConfig, configuration);
  474. if (modelConfig instanceof File) {
  475. configuration.file = modelConfig;
  476. }
  477. } else {
  478. this.configuration.model = configuration;
  479. }
  480. this._isLoading = true;
  481. let model = this.modelLoader.load(configuration);
  482. this.lastUsedLoader = model.loader;
  483. model.onLoadErrorObservable.add((errorObject) => {
  484. this.onModelLoadErrorObservable.notifyObserversWithPromise(errorObject);
  485. });
  486. model.onLoadProgressObservable.add((progressEvent) => {
  487. this.onModelLoadProgressObservable.notifyObserversWithPromise(progressEvent);
  488. });
  489. this.onLoaderInitObservable.notifyObserversWithPromise(this.lastUsedLoader);
  490. model.onLoadedObservable.add(() => {
  491. this._isLoading = false;
  492. });
  493. return model;
  494. }
  495. /**
  496. * load a model using the provided configuration.
  497. * This function, as opposed to initModel, will return a promise that resolves when the model is loaded, and rejects with error.
  498. * If you want to attach to the observables of the model, use initModle instead.
  499. *
  500. * @param modelConfig the model configuration or URL to load.
  501. * @param clearScene Should the scene be cleared before loading the model
  502. * @returns a Promise the fulfills when the model finished loading successfully.
  503. */
  504. public loadModel(modelConfig: string | File | IModelConfiguration, clearScene: boolean = true): Promise<ViewerModel> {
  505. if (this._isLoading) {
  506. // We can decide here whether or not to cancel the lst load, but the developer can do that.
  507. return Promise.reject("another model is curently being loaded.");
  508. }
  509. return Promise.resolve(this.sceneManager.scene).then((scene) => {
  510. if (!scene) return this.sceneManager.initScene(this.configuration.scene, this.configuration.optimizer);
  511. return scene;
  512. }).then(() => {
  513. let model = this.initModel(modelConfig, clearScene);
  514. return new Promise<ViewerModel>((resolve, reject) => {
  515. // at this point, configuration.model is an object, not a string
  516. model.onLoadedObservable.add(() => {
  517. resolve(model);
  518. });
  519. model.onLoadErrorObservable.add((error) => {
  520. reject(error);
  521. });
  522. });
  523. })
  524. }
  525. private _fpsTimeoutInterval: number;
  526. protected _initTelemetryEvents() {
  527. telemetryManager.broadcast("Engine Capabilities", this.baseId, this.engine.getCaps());
  528. telemetryManager.broadcast("Platform Details", this.baseId, {
  529. userAgent: navigator.userAgent,
  530. platform: navigator.platform
  531. });
  532. telemetryManager.flushWebGLErrors(this.engine, this.baseId);
  533. let trackFPS: Function = () => {
  534. telemetryManager.broadcast("Current FPS", this.baseId, { fps: this.engine.getFps() });
  535. };
  536. trackFPS();
  537. // Track the FPS again after 60 seconds
  538. this._fpsTimeoutInterval = window.setInterval(trackFPS, 60 * 1000);
  539. }
  540. /**
  541. * Injects all the spectre shader in the babylon shader store
  542. */
  543. protected _injectCustomShaders(): void {
  544. let customShaders = this.configuration.customShaders;
  545. // Inject all the spectre shader in the babylon shader store.
  546. if (!customShaders) {
  547. return;
  548. }
  549. if (customShaders.shaders) {
  550. Object.keys(customShaders.shaders).forEach(key => {
  551. // typescript considers a callback "unsafe", so... '!'
  552. Effect.ShadersStore[key] = customShaders!.shaders![key];
  553. });
  554. }
  555. if (customShaders.includes) {
  556. Object.keys(customShaders.includes).forEach(key => {
  557. // typescript considers a callback "unsafe", so... '!'
  558. Effect.IncludesShadersStore[key] = customShaders!.includes![key];
  559. });
  560. }
  561. }
  562. }