viewer.ts 25 KB

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