viewer.ts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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. public get configurationContainer() {
  145. return this._configurationContainer;
  146. }
  147. constructor(public containerElement: HTMLElement, initialConfiguration: ViewerConfiguration = {}) {
  148. // if exists, use the container id. otherwise, generate a random string.
  149. if (containerElement.id) {
  150. this.baseId = containerElement.id;
  151. } else {
  152. this.baseId = containerElement.id = 'bjs' + Math.random().toString(32).substr(2, 8);
  153. }
  154. this._registeredOnBeforeRenderFunctions = [];
  155. this._configurationContainer = new ConfigurationContainer();
  156. // add this viewer to the viewer manager
  157. viewerManager.addViewer(this);
  158. this.observablesManager = new ObservablesManager();
  159. this.modelLoader = new ModelLoader(this.observablesManager, this._configurationContainer);
  160. RenderingManager.AUTOCLEAR = false;
  161. // extend the configuration
  162. this._configurationLoader = new ConfigurationLoader();
  163. this._configurationLoader.loadConfiguration(initialConfiguration, (configuration) => {
  164. this._onConfigurationLoaded(configuration);
  165. });
  166. this.onSceneInitObservable.add(() => {
  167. this.updateConfiguration();
  168. });
  169. this.onInitDoneObservable.add(() => {
  170. this._isInit = true;
  171. this.engine.runRenderLoop(this._render);
  172. });
  173. this._prepareContainerElement();
  174. }
  175. /**
  176. * get the baseId of this viewer
  177. */
  178. public getBaseId(): string {
  179. return this.baseId;
  180. }
  181. /**
  182. * Do we have a canvas to render on, and is it a part of the scene
  183. */
  184. public isCanvasInDOM(): boolean {
  185. return !!this._canvas && !!this._canvas.parentElement;
  186. }
  187. /**
  188. * Is the engine currently set to rende even when the page is in background
  189. */
  190. public get renderInBackground() {
  191. return this.engine && this.engine.renderEvenInBackground;
  192. }
  193. /**
  194. * Set the viewer's background rendering flag.
  195. */
  196. public set renderInBackground(value: boolean) {
  197. if (this.engine) {
  198. this.engine.renderEvenInBackground = value;
  199. }
  200. }
  201. /**
  202. * Get the configuration object. This is a reference only.
  203. * The configuration can ONLY be updated using the updateConfiguration function.
  204. * changing this object will have no direct effect on the scene.
  205. */
  206. public get configuration(): ViewerConfiguration {
  207. return this._configurationContainer.configuration;
  208. }
  209. /**
  210. * force resizing the engine.
  211. */
  212. public forceResize() {
  213. this._resize();
  214. }
  215. /**
  216. * The resize function that will be registered with the window object
  217. */
  218. protected _resize = (): void => {
  219. // Only resize if Canvas is in the DOM
  220. if (!this.isCanvasInDOM()) {
  221. return;
  222. }
  223. if (this.canvas.clientWidth <= 0 || this.canvas.clientHeight <= 0) {
  224. return;
  225. }
  226. if (this.configuration.engine && this.configuration.engine.disableResize) {
  227. return;
  228. }
  229. this.engine.resize();
  230. }
  231. protected _onConfigurationLoaded(configuration: ViewerConfiguration) {
  232. this._configurationContainer.configuration = deepmerge(this.configuration || {}, configuration);
  233. if (this.configuration.observers) {
  234. this._configureObservers(this.configuration.observers);
  235. }
  236. // TODO remove this after testing, as this is done in the updateCOnfiguration as well.
  237. if (this.configuration.loaderPlugins) {
  238. Object.keys(this.configuration.loaderPlugins).forEach((name => {
  239. if (this.configuration.loaderPlugins && this.configuration.loaderPlugins[name]) {
  240. this.modelLoader.addPlugin(name);
  241. }
  242. }))
  243. }
  244. this.templateManager = new TemplateManager(this.containerElement);
  245. }
  246. /**
  247. * Force a single render loop execution.
  248. */
  249. public forceRender() {
  250. this._render(true);
  251. }
  252. /**
  253. * render loop that will be executed by the engine
  254. */
  255. protected _render = (force: boolean = false): void => {
  256. if (force || (this.sceneManager.scene && this.sceneManager.scene.activeCamera)) {
  257. if (this.runRenderLoop || force) {
  258. this.engine.performanceMonitor.enable();
  259. this.sceneManager.scene.render();
  260. this.onFrameRenderedObservable.notifyObservers(this);
  261. } else {
  262. this.engine.performanceMonitor.disable();
  263. // update camera instead of rendering
  264. this.sceneManager.scene.activeCamera && this.sceneManager.scene.activeCamera.update();
  265. }
  266. }
  267. }
  268. /**
  269. * Takes a screenshot of the scene and returns it as a base64 encoded png.
  270. * @param callback optional callback that will be triggered when screenshot is done.
  271. * @param width Optional screenshot width (default to 512).
  272. * @param height Optional screenshot height (default to 512).
  273. * @returns a promise with the screenshot data
  274. */
  275. public takeScreenshot(callback?: (data: string) => void, width = 0, height = 0): Promise<string> {
  276. width = width || this.canvas.clientWidth;
  277. height = height || this.canvas.clientHeight;
  278. // Create the screenshot
  279. return new Promise<string>((resolve, reject) => {
  280. try {
  281. BABYLON.Tools.CreateScreenshot(this.engine, this.sceneManager.camera, { width, height }, (data) => {
  282. if (callback) {
  283. callback(data);
  284. }
  285. resolve(data);
  286. });
  287. } catch (e) {
  288. reject(e);
  289. }
  290. });
  291. }
  292. /**
  293. * Update the current viewer configuration with new values.
  294. * Only provided information will be updated, old configuration values will be kept.
  295. * If this.configuration was manually changed, you can trigger this function with no parameters,
  296. * and the entire configuration will be updated.
  297. * @param newConfiguration the partial configuration to update
  298. *
  299. */
  300. public updateConfiguration(newConfiguration: Partial<ViewerConfiguration> = this.configuration) {
  301. // update this.configuration with the new data
  302. this._configurationContainer.configuration = deepmerge(this.configuration || {}, newConfiguration);
  303. this.sceneManager.updateConfiguration(newConfiguration);
  304. // observers in configuration
  305. if (newConfiguration.observers) {
  306. this._configureObservers(newConfiguration.observers);
  307. }
  308. if (newConfiguration.loaderPlugins) {
  309. Object.keys(newConfiguration.loaderPlugins).forEach((name => {
  310. if (newConfiguration.loaderPlugins && newConfiguration.loaderPlugins[name]) {
  311. this.modelLoader.addPlugin(name);
  312. }
  313. }));
  314. }
  315. }
  316. /**
  317. * this is used to register native functions using the configuration object.
  318. * This will configure the observers.
  319. * @param observersConfiguration observers configuration
  320. */
  321. protected _configureObservers(observersConfiguration: IObserversConfiguration) {
  322. if (observersConfiguration.onEngineInit) {
  323. this.onEngineInitObservable.add(window[observersConfiguration.onEngineInit]);
  324. } else {
  325. if (observersConfiguration.onEngineInit === '' && this.configuration.observers && this.configuration.observers!.onEngineInit) {
  326. this.onEngineInitObservable.removeCallback(window[this.configuration.observers!.onEngineInit!]);
  327. }
  328. }
  329. if (observersConfiguration.onSceneInit) {
  330. this.onSceneInitObservable.add(window[observersConfiguration.onSceneInit]);
  331. } else {
  332. if (observersConfiguration.onSceneInit === '' && this.configuration.observers && this.configuration.observers!.onSceneInit) {
  333. this.onSceneInitObservable.removeCallback(window[this.configuration.observers!.onSceneInit!]);
  334. }
  335. }
  336. if (observersConfiguration.onModelLoaded) {
  337. this.onModelLoadedObservable.add(window[observersConfiguration.onModelLoaded]);
  338. } else {
  339. if (observersConfiguration.onModelLoaded === '' && this.configuration.observers && this.configuration.observers!.onModelLoaded) {
  340. this.onModelLoadedObservable.removeCallback(window[this.configuration.observers!.onModelLoaded!]);
  341. }
  342. }
  343. }
  344. /**
  345. * Dispoe the entire viewer including the scene and the engine
  346. */
  347. public dispose() {
  348. if (this._isDisposed) {
  349. return;
  350. }
  351. window.removeEventListener('resize', this._resize);
  352. if (this.sceneManager) {
  353. if (this.sceneManager.scene && this.sceneManager.scene.activeCamera) {
  354. this.sceneManager.scene.activeCamera.detachControl(this.canvas);
  355. }
  356. this.sceneManager.dispose();
  357. }
  358. this._fpsTimeoutInterval && clearInterval(this._fpsTimeoutInterval);
  359. this.observablesManager.dispose();
  360. this.modelLoader.dispose();
  361. if (this.engine) {
  362. this.engine.dispose();
  363. }
  364. viewerManager.removeViewer(this);
  365. this._isDisposed = true;
  366. }
  367. /**
  368. * This will prepare the container element for the viewer
  369. */
  370. protected abstract _prepareContainerElement();
  371. /**
  372. * This function will execute when the HTML templates finished initializing.
  373. * It should initialize the engine and continue execution.
  374. *
  375. * @returns {Promise<AbstractViewer>} The viewer object will be returned after the object was loaded.
  376. */
  377. protected _onTemplatesLoaded(): Promise<AbstractViewer> {
  378. return Promise.resolve(this);
  379. }
  380. /**
  381. * This will force the creation of an engine and a scene.
  382. * It will also load a model if preconfigured.
  383. * But first - it will load the extendible onTemplateLoaded()!
  384. */
  385. protected _onTemplateLoaded(): Promise<AbstractViewer> {
  386. // check if viewer was disposed right after created
  387. if (this._isDisposed) {
  388. return Promise.reject("viewer was disposed");
  389. }
  390. return this._onTemplatesLoaded().then(() => {
  391. let autoLoad = typeof this.configuration.model === 'string' || (this.configuration.model && this.configuration.model.url);
  392. return this._initEngine().then((engine) => {
  393. return this.onEngineInitObservable.notifyObserversWithPromise(engine);
  394. }).then(() => {
  395. this._initTelemetryEvents();
  396. if (autoLoad) {
  397. return this.loadModel(this.configuration.model!).catch(e => { }).then(() => { return this.sceneManager.scene });
  398. } else {
  399. return this.sceneManager.scene || this.sceneManager.initScene(this.configuration.scene);
  400. }
  401. }).then(() => {
  402. return this.onInitDoneObservable.notifyObserversWithPromise(this);
  403. }).catch(e => {
  404. Tools.Warn(e.toString());
  405. return this;
  406. });
  407. })
  408. }
  409. /**
  410. * Initialize the engine. Retruns a promise in case async calls are needed.
  411. *
  412. * @protected
  413. * @returns {Promise<Engine>}
  414. * @memberof Viewer
  415. */
  416. protected _initEngine(): Promise<Engine> {
  417. // init custom shaders
  418. this._injectCustomShaders();
  419. //let canvasElement = this.templateManager.getCanvas();
  420. if (!this.canvas) {
  421. return Promise.reject('Canvas element not found!');
  422. }
  423. let config = this.configuration.engine || {};
  424. // TDO enable further configuration
  425. // check for webgl2 support, force-disable if needed.
  426. if (viewerGlobals.disableWebGL2Support) {
  427. config.engineOptions = config.engineOptions || {};
  428. config.engineOptions.disableWebGL2Support = true;
  429. }
  430. this.engine = new Engine(this.canvas, !!config.antialiasing, config.engineOptions);
  431. // Disable manifest checking
  432. Database.IDBStorageEnabled = false;
  433. if (!config.disableResize) {
  434. window.addEventListener('resize', this._resize);
  435. }
  436. if (this.configuration.engine && this.configuration.engine.adaptiveQuality) {
  437. var scale = Math.max(0.5, 1 / (window.devicePixelRatio || 2));
  438. this.engine.setHardwareScalingLevel(scale);
  439. }
  440. // create a new template manager for this viewer
  441. this.sceneManager = new SceneManager(this.engine, this._configurationContainer, this.observablesManager);
  442. return Promise.resolve(this.engine);
  443. }
  444. private _isLoading: boolean;
  445. /**
  446. * Initialize a model loading. The returned object (a ViewerModel object) will be loaded in the background.
  447. * The difference between this and loadModel is that loadModel will fulfill the promise when the model finished loading.
  448. *
  449. * @param modelConfig model configuration to use when loading the model.
  450. * @param clearScene should the scene be cleared before loading this model
  451. * @returns a ViewerModel object that is not yet fully loaded.
  452. */
  453. public initModel(modelConfig: string | File | IModelConfiguration, clearScene: boolean = true): ViewerModel {
  454. let configuration: IModelConfiguration;
  455. if (typeof modelConfig === 'string') {
  456. configuration = {
  457. url: modelConfig
  458. }
  459. } else if (modelConfig instanceof File) {
  460. configuration = {
  461. file: modelConfig,
  462. root: "file:"
  463. }
  464. } else {
  465. configuration = modelConfig
  466. }
  467. if (!configuration.url && !configuration.file) {
  468. throw new Error("no model provided");
  469. }
  470. if (clearScene) {
  471. this.sceneManager.clearScene(true, false);
  472. }
  473. //merge the configuration for future models:
  474. if (this.configuration.model && typeof this.configuration.model === 'object') {
  475. let globalConfig = deepmerge({}, this.configuration.model)
  476. configuration = deepmerge(globalConfig, configuration);
  477. if (modelConfig instanceof File) {
  478. configuration.file = modelConfig;
  479. }
  480. } else {
  481. this.configuration.model = configuration;
  482. }
  483. this._isLoading = true;
  484. let model = this.modelLoader.load(configuration);
  485. this.lastUsedLoader = model.loader;
  486. model.onLoadErrorObservable.add((errorObject) => {
  487. this.onModelLoadErrorObservable.notifyObserversWithPromise(errorObject);
  488. });
  489. model.onLoadProgressObservable.add((progressEvent) => {
  490. this.onModelLoadProgressObservable.notifyObserversWithPromise(progressEvent);
  491. });
  492. this.onLoaderInitObservable.notifyObserversWithPromise(this.lastUsedLoader);
  493. model.onLoadedObservable.add(() => {
  494. this._isLoading = false;
  495. });
  496. return model;
  497. }
  498. /**
  499. * load a model using the provided configuration.
  500. * This function, as opposed to initModel, will return a promise that resolves when the model is loaded, and rejects with error.
  501. * If you want to attach to the observables of the model, use initModle instead.
  502. *
  503. * @param modelConfig the model configuration or URL to load.
  504. * @param clearScene Should the scene be cleared before loading the model
  505. * @returns a Promise the fulfills when the model finished loading successfully.
  506. */
  507. public loadModel(modelConfig: string | File | IModelConfiguration, clearScene: boolean = true): Promise<ViewerModel> {
  508. if (this._isLoading) {
  509. // We can decide here whether or not to cancel the lst load, but the developer can do that.
  510. return Promise.reject("another model is curently being loaded.");
  511. }
  512. return Promise.resolve(this.sceneManager.scene).then((scene) => {
  513. if (!scene) return this.sceneManager.initScene(this.configuration.scene, this.configuration.optimizer);
  514. return scene;
  515. }).then(() => {
  516. let model = this.initModel(modelConfig, clearScene);
  517. return new Promise<ViewerModel>((resolve, reject) => {
  518. // at this point, configuration.model is an object, not a string
  519. model.onLoadedObservable.add(() => {
  520. resolve(model);
  521. });
  522. model.onLoadErrorObservable.add((error) => {
  523. reject(error);
  524. });
  525. });
  526. })
  527. }
  528. private _fpsTimeoutInterval: number;
  529. protected _initTelemetryEvents() {
  530. telemetryManager.broadcast("Engine Capabilities", this.baseId, this.engine.getCaps());
  531. telemetryManager.broadcast("Platform Details", this.baseId, {
  532. userAgent: navigator.userAgent,
  533. platform: navigator.platform
  534. });
  535. telemetryManager.flushWebGLErrors(this.engine, this.baseId);
  536. let trackFPS: Function = () => {
  537. telemetryManager.broadcast("Current FPS", this.baseId, { fps: this.engine.getFps() });
  538. };
  539. trackFPS();
  540. // Track the FPS again after 60 seconds
  541. this._fpsTimeoutInterval = window.setInterval(trackFPS, 60 * 1000);
  542. }
  543. /**
  544. * Injects all the spectre shader in the babylon shader store
  545. */
  546. protected _injectCustomShaders(): void {
  547. let customShaders = this.configuration.customShaders;
  548. // Inject all the spectre shader in the babylon shader store.
  549. if (!customShaders) {
  550. return;
  551. }
  552. if (customShaders.shaders) {
  553. Object.keys(customShaders.shaders).forEach(key => {
  554. // typescript considers a callback "unsafe", so... '!'
  555. Effect.ShadersStore[key] = customShaders!.shaders![key];
  556. });
  557. }
  558. if (customShaders.includes) {
  559. Object.keys(customShaders.includes).forEach(key => {
  560. // typescript considers a callback "unsafe", so... '!'
  561. Effect.IncludesShadersStore[key] = customShaders!.includes![key];
  562. });
  563. }
  564. }
  565. }