"use strict";
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const three_module = require("../../../../../../../../node_modules/.pnpm/three@0.145.0/node_modules/three/build/three.module.js");
require("../../../../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.js");
require("../../../../../../../../node_modules/.pnpm/screenfull@6.0.2/node_modules/screenfull/index.js");
require("../../../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js");
require("../../../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.js");
require("../../../../../../../../node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js");
require("../../../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseClone.js");
require("../../../../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.js");
require("../../../../../../../enums/pageEnum.js");
require("../../../../../../../router/index.js");
require("../../../../../../../store/modules/designStore/designStore.js");
const plugin = require("../../../../../../../utils/plugin.js");
require("../../../../../../../components/GoLoading/index.js");
const Assets = require("./Assets.js");
class Resources {
  constructor(callback) {
    __publicField(this, "manager");
    __publicField(this, "callback");
    __publicField(this, "textureLoader");
    __publicField(this, "textures");
    this.callback = callback;
    this.textures = {};
    this.setLoadingManager();
    this.loadResources();
  }
  /**
   * 管理加载状态
   */
  setLoadingManager() {
    this.manager = new three_module.LoadingManager();
    this.manager.onStart = () => {
      plugin.loadingStart();
    };
    this.manager.onLoad = () => {
      this.callback();
    };
    this.manager.onProgress = (url) => {
      plugin.loadingFinish();
    };
    this.manager.onError = (url) => {
      plugin.loadingError();
      window["$message"].error("数据加载失败，请刷新重试！");
    };
  }
  /**
   * 加载资源
   */
  loadResources() {
    var _a;
    this.textureLoader = new three_module.TextureLoader(this.manager);
    (_a = Assets.resources.textures) == null ? void 0 : _a.forEach((item) => {
      this.textureLoader.load(item.url, (t) => {
        this.textures[item.name] = t;
      });
    });
  }
}
exports.Resources = Resources;
