applyMaterialConfig.ts 763 B

123456789101112131415161718192021
  1. import { ILoaderPlugin } from "./loaderPlugin";
  2. import { telemetryManager } from "../../telemetryManager";
  3. import { ViewerModel } from "../..";
  4. import { Tools, ISceneLoaderPlugin, ISceneLoaderPluginAsync, Material } from "babylonjs";
  5. import { IGLTFLoaderData, GLTF2 } from "babylonjs-loaders";
  6. /**
  7. * Force-apply material configuration right after a material was loaded.
  8. */
  9. export class ApplyMaterialConfigPlugin implements ILoaderPlugin {
  10. private _model: ViewerModel;
  11. public onInit(loader: ISceneLoaderPlugin | ISceneLoaderPluginAsync, model: ViewerModel) {
  12. this._model = model;
  13. }
  14. public onMaterialLoaded(material: Material) {
  15. this._model && this._model._applyModelMaterialConfiguration(material);
  16. }
  17. }