@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
27 lines (26 loc) • 718 B
JavaScript
;
export class BaseModulesRegister {
constructor(poly) {
this.poly = poly;
this._moduleByName = /* @__PURE__ */ new Map();
}
register(moduleName, module, options) {
let printWarnings = options == null ? void 0 : options.printWarnings;
if (printWarnings == null) {
printWarnings = true;
}
if (this._moduleByName.has(moduleName) && printWarnings) {
console.warn("module already registered", moduleName);
return;
}
this._moduleByName.set(moduleName, module);
module.onRegister(this.poly);
}
moduleNames() {
const list = [];
this._moduleByName.forEach((module, moduleName) => {
list.push(moduleName);
});
return list;
}
}