applyMaterialConfig.ts 721 B

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