defaultViewer.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. import { ViewerConfiguration, IModelConfiguration, ILightConfiguration } from './../configuration';
  2. import { Template, EventCallback } from '../templating/templateManager';
  3. import { AbstractViewer } from './viewer';
  4. import { SpotLight, Vector3, FilesInput } from 'babylonjs';
  5. import { ViewerModel } from '../model/viewerModel';
  6. import { IModelAnimation, AnimationState } from '../model/modelAnimation';
  7. import { IViewerTemplatePlugin } from '../templating/viewerTemplatePlugin';
  8. import { HDButtonPlugin } from '../templating/plugins/hdButtonPlugin';
  9. /**
  10. * The Default viewer is the default implementation of the AbstractViewer.
  11. * It uses the templating system to render a new canvas and controls.
  12. */
  13. export class DefaultViewer extends AbstractViewer {
  14. public fullscreenElement?: HTMLElement;
  15. /**
  16. * Create a new default viewer
  17. * @param containerElement the element in which the templates will be rendered
  18. * @param initialConfiguration the initial configuration. Defaults to extending the default configuration
  19. */
  20. constructor(public containerElement: HTMLElement, initialConfiguration: ViewerConfiguration = { extends: 'default' }) {
  21. super(containerElement, initialConfiguration);
  22. this.onModelLoadedObservable.add(this._onModelLoaded);
  23. this.onModelRemovedObservable.add(() => {
  24. this._configureTemplate();
  25. })
  26. this.onEngineInitObservable.add(() => {
  27. this.sceneManager.onLightsConfiguredObservable.add((data) => {
  28. this._configureLights();
  29. })
  30. });
  31. this.onInitDoneObservable.add(() => {
  32. if (!this.sceneManager.models.length) {
  33. this.hideLoadingScreen();
  34. }
  35. })
  36. }
  37. private _registeredPlugins: Array<IViewerTemplatePlugin> = [];
  38. public registerTemplatePlugin(plugin: IViewerTemplatePlugin) {
  39. //validate
  40. if (!plugin.templateName) {
  41. throw new Error("No template name provided");
  42. }
  43. this._registeredPlugins.push(plugin);
  44. let template = this.templateManager.getTemplate(plugin.templateName);
  45. if (!template) {
  46. throw new Error(`Template ${plugin.templateName} not found`);
  47. }
  48. if (plugin.addHTMLTemplate) {
  49. template.onHTMLRendered.add((tmpl) => {
  50. plugin.addHTMLTemplate!(tmpl);
  51. });
  52. template.redraw();
  53. }
  54. if (plugin.eventsToAttach) {
  55. plugin.eventsToAttach.forEach(eventName => {
  56. plugin.onEvent && this.templateManager.eventManager.registerCallback(plugin.templateName, (event) => {
  57. if (plugin.onEvent && plugin.interactionPredicate(event)) {
  58. plugin.onEvent(event);
  59. }
  60. }, eventName);
  61. });
  62. }
  63. }
  64. /**
  65. * This will be executed when the templates initialize.
  66. */
  67. protected _onTemplatesLoaded() {
  68. this.showLoadingScreen();
  69. // navbar
  70. this._initNavbar();
  71. // close overlay button
  72. let template = this.templateManager.getTemplate('overlay');
  73. if (template) {
  74. let closeButton = template.parent.querySelector('.close-button');
  75. if (closeButton) {
  76. closeButton.addEventListener('pointerdown', () => {
  77. this.hideOverlayScreen();
  78. });
  79. }
  80. }
  81. if (this.configuration.templates && this.configuration.templates.viewer) {
  82. if (this.configuration.templates.viewer.params && this.configuration.templates.viewer.params.enableDragAndDrop) {
  83. this.onSceneInitObservable.addOnce(() => {
  84. let filesInput = new FilesInput(this.engine, this.sceneManager.scene, () => {
  85. }, () => {
  86. }, () => {
  87. }, () => {
  88. }, function () {
  89. }, (file: File) => {
  90. this.loadModel(file);
  91. }, () => {
  92. });
  93. filesInput.monitorElementForDragNDrop(this.templateManager.getCanvas()!);
  94. })
  95. }
  96. }
  97. return super._onTemplatesLoaded();
  98. }
  99. private _initNavbar() {
  100. let navbar = this.templateManager.getTemplate('navBar');
  101. if (navbar) {
  102. this.onFrameRenderedObservable.add(this._updateProgressBar);
  103. this.templateManager.eventManager.registerCallback('navBar', this._handlePointerDown, 'pointerdown');
  104. // an example how to trigger the help button. publiclly available
  105. this.templateManager.eventManager.registerCallback("navBar", () => {
  106. // do your thing
  107. }, "pointerdown", ".help-button");
  108. this.templateManager.eventManager.registerCallback("navBar", (event: EventCallback) => {
  109. const evt = event.event;
  110. const element = <HTMLInputElement>(evt.target);
  111. if (!this._currentAnimation) return;
  112. const gotoFrame = +element.value / 100 * this._currentAnimation.frames;
  113. if (isNaN(gotoFrame)) return;
  114. this._currentAnimation.goToFrame(gotoFrame);
  115. }, "input");
  116. this.templateManager.eventManager.registerCallback("navBar", () => {
  117. if (this._resumePlay) {
  118. this._togglePlayPause(true);
  119. }
  120. this._resumePlay = false;
  121. }, "pointerup", ".progress-wrapper");
  122. if (window.devicePixelRatio === 1 && navbar.configuration.params && !navbar.configuration.params.hideHdButton) {
  123. navbar.updateParams({
  124. hideHdButton: true
  125. });
  126. }
  127. this.registerTemplatePlugin(new HDButtonPlugin(this));
  128. }
  129. }
  130. private _animationList: string[];
  131. private _currentAnimation: IModelAnimation;
  132. private _isAnimationPaused: boolean;
  133. private _resumePlay: boolean;
  134. private _handlePointerDown = (event: EventCallback) => {
  135. let pointerDown = <PointerEvent>event.event;
  136. if (pointerDown.button !== 0) return;
  137. var element = (<HTMLElement>event.event.target);
  138. if (!element) {
  139. return;
  140. }
  141. let parentClasses = element.parentElement!.classList;
  142. let elementClasses = element.classList;
  143. let elementName = "";
  144. for (let i = 0; i < elementClasses.length; ++i) {
  145. let className = elementClasses[i];
  146. if (className.indexOf("-button") !== -1 || className.indexOf("-wrapper") !== -1) {
  147. elementName = className;
  148. break;
  149. }
  150. }
  151. switch (elementName) {
  152. case "speed-button":
  153. case "types-button":
  154. if (parentClasses.contains("open")) {
  155. parentClasses.remove("open");
  156. } else {
  157. parentClasses.add("open");
  158. }
  159. break;
  160. case "play-pause-button":
  161. this._togglePlayPause();
  162. break;
  163. case "label-option-button":
  164. var value = element.dataset["value"];
  165. var label = element.querySelector("span.animation-label");
  166. if (label && value) {
  167. this._updateAnimationType({ value, label: label.innerHTML });
  168. }
  169. break;
  170. case "speed-option-button":
  171. if (!this._currentAnimation) {
  172. return;
  173. }
  174. var speed = element.dataset["value"];
  175. if (speed)
  176. this._updateAnimationSpeed(speed);
  177. break;
  178. case "progress-wrapper":
  179. this._resumePlay = !this._isAnimationPaused;
  180. if (this._resumePlay) {
  181. this._togglePlayPause(true);
  182. }
  183. break;
  184. case "fullscreen-button":
  185. this.toggleFullscreen();
  186. break;
  187. case "vr-button":
  188. this.toggleVR();
  189. break;
  190. default:
  191. return;
  192. }
  193. }
  194. /**
  195. * Plays or Pauses animation
  196. */
  197. private _togglePlayPause = (noUiUpdate?: boolean) => {
  198. if (!this._currentAnimation) {
  199. return;
  200. }
  201. if (this._isAnimationPaused) {
  202. this._currentAnimation.restart();
  203. } else {
  204. this._currentAnimation.pause();
  205. }
  206. this._isAnimationPaused = !this._isAnimationPaused;
  207. if (noUiUpdate) return;
  208. let navbar = this.templateManager.getTemplate('navBar');
  209. if (!navbar) return;
  210. navbar.updateParams({
  211. paused: this._isAnimationPaused,
  212. });
  213. }
  214. private _oldIdleRotationValue: number;
  215. /**
  216. * Control progress bar position based on animation current frame
  217. */
  218. private _updateProgressBar = () => {
  219. let navbar = this.templateManager.getTemplate('navBar');
  220. if (!navbar) return;
  221. var progressSlider = <HTMLInputElement>navbar.parent.querySelector("input.progress-wrapper");
  222. if (progressSlider && this._currentAnimation) {
  223. const progress = this._currentAnimation.currentFrame / this._currentAnimation.frames * 100;
  224. var currentValue = progressSlider.valueAsNumber;
  225. if (Math.abs(currentValue - progress) > 0.5) { // Only move if greater than a 1% change
  226. progressSlider.value = '' + progress;
  227. }
  228. if (this._currentAnimation.state === AnimationState.PLAYING) {
  229. if (this.sceneManager.camera.autoRotationBehavior && !this._oldIdleRotationValue) {
  230. this._oldIdleRotationValue = this.sceneManager.camera.autoRotationBehavior.idleRotationSpeed;
  231. this.sceneManager.camera.autoRotationBehavior.idleRotationSpeed = 0;
  232. }
  233. } else {
  234. if (this.sceneManager.camera.autoRotationBehavior && this._oldIdleRotationValue) {
  235. this.sceneManager.camera.autoRotationBehavior.idleRotationSpeed = this._oldIdleRotationValue;
  236. this._oldIdleRotationValue = 0;
  237. }
  238. }
  239. }
  240. }
  241. /**
  242. * Update Current Animation Speed
  243. */
  244. private _updateAnimationSpeed = (speed: string, paramsObject?: any) => {
  245. let navbar = this.templateManager.getTemplate('navBar');
  246. if (!navbar) return;
  247. if (speed && this._currentAnimation) {
  248. this._currentAnimation.speedRatio = parseFloat(speed);
  249. if (!this._isAnimationPaused) {
  250. this._currentAnimation.restart();
  251. }
  252. if (paramsObject) {
  253. paramsObject.selectedSpeed = speed + "x"
  254. } else {
  255. navbar.updateParams({
  256. selectedSpeed: speed + "x",
  257. });
  258. }
  259. }
  260. }
  261. /**
  262. * Update Current Animation Type
  263. */
  264. private _updateAnimationType = (data: { label: string, value: string }, paramsObject?: any) => {
  265. let navbar = this.templateManager.getTemplate('navBar');
  266. if (!navbar) return;
  267. if (data) {
  268. this._currentAnimation = this.sceneManager.models[0].setCurrentAnimationByName(data.value);
  269. }
  270. if (paramsObject) {
  271. paramsObject.selectedAnimation = (this._animationList.indexOf(data.value) + 1);
  272. paramsObject.selectedAnimationName = data.label;
  273. } else {
  274. navbar.updateParams({
  275. selectedAnimation: (this._animationList.indexOf(data.value) + 1),
  276. selectedAnimationName: data.label
  277. });
  278. }
  279. this._updateAnimationSpeed("1.0", paramsObject);
  280. }
  281. public toggleVR() {
  282. super.toggleVR();
  283. let viewerTemplate = this.templateManager.getTemplate('viewer');
  284. let viewerElement = viewerTemplate && viewerTemplate.parent;
  285. if (viewerElement) {
  286. if (this._vrToggled) {
  287. viewerElement.classList.add("in-vr");
  288. } else {
  289. viewerElement.classList.remove("in-vr");
  290. }
  291. }
  292. }
  293. /**
  294. * Toggle fullscreen of the entire viewer
  295. */
  296. public toggleFullscreen = () => {
  297. let viewerTemplate = this.templateManager.getTemplate('viewer');
  298. let viewerElement = viewerTemplate && viewerTemplate.parent;
  299. let fullscreenElement = this.fullscreenElement || viewerElement;
  300. if (fullscreenElement) {
  301. let currentElement = document.fullscreenElement || document.webkitFullscreenElement || (<any>document).mozFullScreenElement || (<any>document).msFullscreenElement;
  302. if (!currentElement) {
  303. let requestFullScreen = fullscreenElement.requestFullscreen || fullscreenElement.webkitRequestFullscreen || (<any>fullscreenElement).msRequestFullscreen || (<any>fullscreenElement).mozRequestFullScreen;
  304. requestFullScreen.call(fullscreenElement);
  305. if (viewerElement) {
  306. viewerElement.classList.add("in-fullscreen");
  307. }
  308. } else {
  309. let exitFullscreen = document.exitFullscreen || document.webkitExitFullscreen || (<any>document).msExitFullscreen || (<any>document).mozCancelFullScreen
  310. exitFullscreen.call(document);
  311. if (viewerElement) {
  312. viewerElement.classList.remove("in-fullscreen");
  313. }
  314. }
  315. }
  316. }
  317. /**
  318. * Preparing the container element to present the viewer
  319. */
  320. protected _prepareContainerElement() {
  321. this.containerElement.style.position = 'relative';
  322. this.containerElement.style.height = '100%';
  323. this.containerElement.style.display = 'flex';
  324. }
  325. /**
  326. * This function will configure the templates and update them after a model was loaded
  327. * It is mainly responsible to changing the title and subtitle etc'.
  328. * @param model the model to be used to configure the templates by
  329. */
  330. protected _configureTemplate(model?: ViewerModel) {
  331. let navbar = this.templateManager.getTemplate('navBar');
  332. if (!navbar) return;
  333. let newParams: any = navbar.configuration.params || {};
  334. if (!model) {
  335. newParams.animations = null;
  336. } else {
  337. let animationNames = model.getAnimationNames();
  338. newParams.animations = animationNames.map(a => { return { label: a, value: a } });
  339. if (animationNames.length) {
  340. this._isAnimationPaused = (model.configuration.animation && !model.configuration.animation.autoStart) || !model.configuration.animation;
  341. this._animationList = animationNames;
  342. newParams.paused = this._isAnimationPaused;
  343. let animationIndex = 0;
  344. if (model.configuration.animation && typeof model.configuration.animation.autoStart === 'string') {
  345. animationIndex = animationNames.indexOf(model.configuration.animation.autoStart);
  346. if (animationIndex === -1) {
  347. animationIndex = 0;
  348. }
  349. }
  350. this._updateAnimationType(newParams.animations[animationIndex], newParams);
  351. } else {
  352. newParams.animations = null;
  353. }
  354. if (model.configuration.thumbnail) {
  355. newParams.logoImage = model.configuration.thumbnail
  356. }
  357. }
  358. navbar.updateParams(newParams, false);
  359. }
  360. /**
  361. * This will load a new model to the default viewer
  362. * overriding the AbstractViewer's loadModel.
  363. * The scene will automatically be cleared of the old models, if exist.
  364. * @param model the configuration object (or URL) to load.
  365. */
  366. public loadModel(model?: string | File | IModelConfiguration): Promise<ViewerModel> {
  367. if (!model) {
  368. model = this.configuration.model;
  369. }
  370. this.showLoadingScreen();
  371. return super.loadModel(model!, true).catch((error) => {
  372. console.log(error);
  373. this.hideLoadingScreen();
  374. this.showOverlayScreen('error');
  375. return Promise.reject(error);
  376. });
  377. }
  378. private _onModelLoaded = (model: ViewerModel) => {
  379. this._configureTemplate(model);
  380. // with a short timeout, making sure everything is there already.
  381. let hideLoadingDelay = 20;
  382. if (this.configuration.lab && this.configuration.lab.hideLoadingDelay !== undefined) {
  383. hideLoadingDelay = this.configuration.lab.hideLoadingDelay;
  384. }
  385. setTimeout(() => {
  386. this.sceneManager.scene.executeWhenReady(() => {
  387. this.hideLoadingScreen();
  388. });
  389. }, hideLoadingDelay);
  390. return;
  391. }
  392. /**
  393. * Show the overlay and the defined sub-screen.
  394. * Mainly used for help and errors
  395. * @param subScreen the name of the subScreen. Those can be defined in the configuration object
  396. */
  397. public showOverlayScreen(subScreen: string) {
  398. let template = this.templateManager.getTemplate('overlay');
  399. if (!template) return Promise.resolve('Overlay template not found');
  400. return template.show((template => {
  401. var canvasRect = this.containerElement.getBoundingClientRect();
  402. template.parent.style.display = 'flex';
  403. template.parent.style.width = canvasRect.width + "px";
  404. template.parent.style.height = canvasRect.height + "px";
  405. template.parent.style.opacity = "1";
  406. let subTemplate = this.templateManager.getTemplate(subScreen);
  407. if (!subTemplate) {
  408. return Promise.reject(subScreen + ' template not found');
  409. }
  410. return subTemplate.show((template => {
  411. template.parent.style.display = 'flex';
  412. return Promise.resolve(template);
  413. }));
  414. }));
  415. }
  416. /**
  417. * Hide the overlay screen.
  418. */
  419. public hideOverlayScreen() {
  420. let template = this.templateManager.getTemplate('overlay');
  421. if (!template) return Promise.resolve('Overlay template not found');
  422. return template.hide((template => {
  423. template.parent.style.opacity = "0";
  424. let onTransitionEnd = () => {
  425. template.parent.removeEventListener("transitionend", onTransitionEnd);
  426. template.parent.style.display = 'none';
  427. }
  428. template.parent.addEventListener("transitionend", onTransitionEnd);
  429. let overlays = template.parent.querySelectorAll('.overlay');
  430. if (overlays) {
  431. for (let i = 0; i < overlays.length; ++i) {
  432. let htmlElement = <HTMLElement>overlays.item(i);
  433. htmlElement.style.display = 'none';
  434. }
  435. }
  436. return Promise.resolve(template);
  437. }));
  438. }
  439. /**
  440. * show the viewer (in case it was hidden)
  441. *
  442. * @param visibilityFunction an optional function to execute in order to show the container
  443. */
  444. public show(visibilityFunction?: ((template: Template) => Promise<Template>)): Promise<Template> {
  445. let template = this.templateManager.getTemplate('main');
  446. //not possible, but yet:
  447. if (!template) return Promise.reject('Main template not found');
  448. return template.show(visibilityFunction);
  449. }
  450. /**
  451. * hide the viewer (in case it is visible)
  452. *
  453. * @param visibilityFunction an optional function to execute in order to hide the container
  454. */
  455. public hide(visibilityFunction?: ((template: Template) => Promise<Template>)) {
  456. let template = this.templateManager.getTemplate('main');
  457. //not possible, but yet:
  458. if (!template) return Promise.reject('Main template not found');
  459. return template.hide(visibilityFunction);
  460. }
  461. /**
  462. * Show the loading screen.
  463. * The loading screen can be configured using the configuration object
  464. */
  465. public showLoadingScreen() {
  466. let template = this.templateManager.getTemplate('loadingScreen');
  467. if (!template) return Promise.resolve('Loading Screen template not found');
  468. return template.show((template => {
  469. var canvasRect = this.containerElement.getBoundingClientRect();
  470. // var canvasPositioning = window.getComputedStyle(this.containerElement).position;
  471. template.parent.style.display = 'flex';
  472. template.parent.style.width = canvasRect.width + "px";
  473. template.parent.style.height = canvasRect.height + "px";
  474. template.parent.style.opacity = "1";
  475. // from the configuration!!!
  476. let color = "black";
  477. if (this.configuration.templates && this.configuration.templates.loadingScreen) {
  478. color = (this.configuration.templates.loadingScreen.params &&
  479. <string>this.configuration.templates.loadingScreen.params.backgroundColor) || color;
  480. }
  481. template.parent.style.backgroundColor = color;
  482. return Promise.resolve(template);
  483. }));
  484. }
  485. /**
  486. * Hide the loading screen
  487. */
  488. public hideLoadingScreen() {
  489. let template = this.templateManager.getTemplate('loadingScreen');
  490. if (!template) return Promise.resolve('Loading Screen template not found');
  491. return template.hide((template => {
  492. template.parent.style.opacity = "0";
  493. let onTransitionEnd = () => {
  494. template.parent.removeEventListener("transitionend", onTransitionEnd);
  495. template.parent.style.display = 'none';
  496. }
  497. template.parent.addEventListener("transitionend", onTransitionEnd);
  498. return Promise.resolve(template);
  499. }));
  500. }
  501. public dispose() {
  502. this.templateManager.dispose();
  503. super.dispose();
  504. }
  505. protected _onConfigurationLoaded(configuration: ViewerConfiguration) {
  506. super._onConfigurationLoaded(configuration);
  507. // initialize the templates
  508. let templateConfiguration = this.configuration.templates || {};
  509. this.templateManager.initTemplate(templateConfiguration);
  510. // when done, execute onTemplatesLoaded()
  511. this.templateManager.onAllLoaded.add(() => {
  512. let canvas = this.templateManager.getCanvas();
  513. if (canvas) {
  514. this._canvas = canvas;
  515. }
  516. this._onTemplateLoaded();
  517. });
  518. }
  519. /**
  520. * An extension of the light configuration of the abstract viewer.
  521. * @param lightsConfiguration the light configuration to use
  522. * @param model the model that will be used to configure the lights (if the lights are model-dependant)
  523. */
  524. private _configureLights() {
  525. // labs feature - flashlight
  526. if (this.configuration.lab && this.configuration.lab.flashlight) {
  527. let lightTarget;
  528. let angle = 0.5;
  529. let exponent = Math.PI / 2;
  530. if (typeof this.configuration.lab.flashlight === "object") {
  531. exponent = this.configuration.lab.flashlight.exponent || exponent;
  532. angle = this.configuration.lab.flashlight.angle || angle;
  533. }
  534. var flashlight = new SpotLight("flashlight", Vector3.Zero(),
  535. Vector3.Zero(), exponent, angle, this.sceneManager.scene);
  536. if (typeof this.configuration.lab.flashlight === "object") {
  537. flashlight.intensity = this.configuration.lab.flashlight.intensity || flashlight.intensity;
  538. if (this.configuration.lab.flashlight.diffuse) {
  539. flashlight.diffuse.r = this.configuration.lab.flashlight.diffuse.r;
  540. flashlight.diffuse.g = this.configuration.lab.flashlight.diffuse.g;
  541. flashlight.diffuse.b = this.configuration.lab.flashlight.diffuse.b;
  542. }
  543. if (this.configuration.lab.flashlight.specular) {
  544. flashlight.specular.r = this.configuration.lab.flashlight.specular.r;
  545. flashlight.specular.g = this.configuration.lab.flashlight.specular.g;
  546. flashlight.specular.b = this.configuration.lab.flashlight.specular.b;
  547. }
  548. }
  549. this.sceneManager.scene.constantlyUpdateMeshUnderPointer = true;
  550. this.sceneManager.scene.onPointerObservable.add((eventData) => {
  551. if (eventData.type === 4 && eventData.pickInfo) {
  552. lightTarget = (eventData.pickInfo.pickedPoint);
  553. } else {
  554. lightTarget = undefined;
  555. }
  556. });
  557. let updateFlashlightFunction = () => {
  558. if (this.sceneManager.camera && flashlight) {
  559. flashlight.position.copyFrom(this.sceneManager.camera.position);
  560. if (lightTarget) {
  561. lightTarget.subtractToRef(flashlight.position, flashlight.direction);
  562. }
  563. }
  564. }
  565. this.sceneManager.scene.registerBeforeRender(updateFlashlightFunction);
  566. this._registeredOnBeforeRenderFunctions.push(updateFlashlightFunction);
  567. }
  568. }
  569. }